Skip to content

👌 Improve footnote def/ref warnings and translations #931

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 10 commits into from
Aug 5, 2024
Prev Previous commit
Next Next commit
small code refactor
  • Loading branch information
chrisjsewell committed May 25, 2024
commit 0961450b9c7a26608d445eb5c03ab3ff9e1a6fd8
18 changes: 9 additions & 9 deletions myst_parser/mdit_to_docutils/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -1504,13 +1504,13 @@ def render_footnote_ref(self, token: SyntaxTreeNode) -> None:

refnode = nodes.footnote_reference(f"[^{target}]")
self.add_line_and_source_path(refnode, token)
if not target.isdigit():
if target.isdigit():
# a manually numbered footnote, similar to rST ``[1]_``
refnode += nodes.Text(target)
else:
# an auto-numbered footnote, similar to rST ``[#label]_``
refnode["auto"] = 1
self.document.note_autofootnote_ref(refnode)
else:
# a manually numbered footnote, similar to rST ``[1]_``
refnode += nodes.Text(target)

refnode["refname"] = target
self.document.note_footnote_ref(refnode)
Expand All @@ -1524,14 +1524,14 @@ def render_footnote_reference(self, token: SyntaxTreeNode) -> None:
footnote = nodes.footnote()
self.add_line_and_source_path(footnote, token)
footnote["names"].append(target)
if not target.isdigit():
# an auto-numbered footnote, similar to rST ``.. [#label]``
footnote["auto"] = 1
self.document.note_autofootnote(footnote)
else:
if target.isdigit():
# a manually numbered footnote, similar to rST ``.. [1]``
footnote += nodes.label("", target)
self.document.note_footnote(footnote)
else:
# an auto-numbered footnote, similar to rST ``.. [#label]``
footnote["auto"] = 1
self.document.note_autofootnote(footnote)

self.document.note_explicit_target(footnote, footnote)
with self.current_node_context(footnote, append=True):
Expand Down