Skip to content

Commit 44a6b09

Browse files
authored
Rename refrepl to replace_reference to improve clarity (hellt#9)
* Rename refrepl to reference_replace to improve clarity * Change function name to be replace_reference (verb, then noun)
1 parent 5b35c90 commit 44a6b09

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

fnsort.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ def parse_arguments():
4242
label = re.compile(r"^\[\^([^\]]+)\]:\s*((?:(?!\n\[)[\s\S])*)", re.MULTILINE)
4343

4444

45-
def refrepl(m, order):
45+
def replace_reference(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.
4848
return f"{m.group(0)[:1]}[^{order.index(m.group(2)) + 1}]"
@@ -75,7 +75,7 @@ def sort_footnotes(text):
7575
# print(f"text: {text}")
7676

7777
# Rewrite the footnote-links with the new footnote-reference numbers.
78-
text = link.sub(lambda m: refrepl(m, order), text)
78+
text = link.sub(lambda m: replace_reference(m, order), text)
7979

8080
return text
8181

tests/test_footnote_sorting.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ def test_replace_reference(self):
3030

3131
# hedgehogs[^1]
3232
self.assertEqual(
33-
fnsort.refrepl(match, order),
33+
fnsort.replace_reference(match, order),
3434
"s[^1]"
3535
)
3636

@@ -69,7 +69,7 @@ def test_replace_references_with_dups(self):
6969
# multiple assertions
7070
for i, match in enumerate(matches):
7171
self.assertEqual(
72-
fnsort.refrepl(match, order),
72+
fnsort.replace_reference(match, order),
7373
expected[i]
7474
)
7575

0 commit comments

Comments
 (0)