Skip to content

Commit

Permalink
Merge pull request #108 from shyamd/fix-inline-numbering
Browse files Browse the repository at this point in the history
Fix inline citation numbering
  • Loading branch information
shyamd authored Feb 21, 2022
2 parents 82e7e4b + d011c2d commit ff47f5c
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/mkdocs_bibtex/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ def format_citations(self, cite_keys):
# Deal with arithmatex fix at some point

# 1. First collect any unformated references
entries = {}
entries = OrderedDict()
for key_set in cite_keys:
for key in key_set.strip().strip("]").strip("[").split(";"):
key = key.strip().strip("@")
Expand All @@ -138,10 +138,10 @@ def format_citations(self, cite_keys):

# 3. Construct quads
quads = []
for key_set in cite_keys:
for n, key_set in enumerate(cite_keys):
for key in key_set.strip().strip("]").strip("[").split(";"):
key = key.strip().strip("@")
quads.append((key_set, key, "1", self.all_references[key]))
quads.append((key_set, key, str(n + 1), self.all_references[key]))

return quads

Expand Down
4 changes: 4 additions & 0 deletions test_files/test_plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -223,3 +223,7 @@ def test_on_page_markdown(plugin):
"[^1]: First Author and Second Author. Test title. *Testing Journal*, 2019."
in plugin.on_page_markdown(test_markdown, None, None, None)
)

test_markdown = "This is a citation. [@test] This is another citation [@test2]\n\n \\bibliography"
# ensure there are two items in bibliography
assert "[^2]:" in plugin.on_page_markdown(test_markdown, None, None, None)

0 comments on commit ff47f5c

Please sign in to comment.