Skip to content

Commit 5b35c90

Browse files
authored
Use format strings instead of old-style strings (hellt#8)
* Modify reference replace function to use f-string * Replace string with f-string in sort_footnotes function
1 parent 7f4befe commit 5b35c90

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

fnsort.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ def parse_arguments():
4545
def refrepl(m, order):
4646
# Rewrite reference links with the reordered link numbers. Insert the first
4747
# character from the footnote reference link right before the new link.
48-
return "%s[^%s]" % (m.group(0)[:1], order.index(m.group(2)) + 1)
48+
return f"{m.group(0)[:1]}[^{order.index(m.group(2)) + 1}]"
4949

5050

5151
def sort_footnotes(text):
@@ -67,7 +67,7 @@ def sort_footnotes(text):
6767

6868
# Make a list of the footnote-references in order of appearance the original footnotes in text.
6969
# this is not the order of the footnote contents, but the order of the footnote references in the text.
70-
newlabels = ["[^%s]: %s" % (i + 1, labels[j]) for (i, j) in enumerate(order)]
70+
newlabels = [f"[^{i+1}]: {labels[j]}" for (i, j) in enumerate(order)]
7171
# print(f"newlabels: {newlabels}")
7272

7373
# Remove the old footnote-references and put the new ones at the end of the text.

0 commit comments

Comments
 (0)