-
Notifications
You must be signed in to change notification settings - Fork 198
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
👌 Improve footnote def/ref warnings and translations #931
Conversation
Add warnings (with source mapping) for unused footnote definitions and footnote references that have no definition.
All good @asmeurer 😄 ? |
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #931 +/- ##
==========================================
- Coverage 90.34% 90.30% -0.04%
==========================================
Files 24 24
Lines 3469 3507 +38
==========================================
+ Hits 3134 3167 +33
- Misses 335 340 +5
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
I tried this but I got an exception:
|
you haven't updated your mdit-py-plugins version |
I have the latest version from conda. Is there a dev version I need to use? |
yeh it was only released on pypi today, so this has only just appeared conda-forge/mdit-py-plugins-feedstock#21 |
OK, I was able to get it working. Two things I noticed:
|
myst_parser/mdit_to_docutils/base.py
Outdated
# lets remove the footnote references, so that docutils does not produce any more warnings | ||
# we need to replace them with an element though, so that ids can be moved over (otherwise docutils excepts) | ||
if node.get("auto"): | ||
self.document.autofootnote_refs.remove(node) | ||
node.replace_self(nodes.inline(text=f"[^{node['refname']}]")) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
code to suppress docutils warnings
footnote reference with no definition | ||
. | ||
[^a] | ||
. | ||
<string>:1: (WARNING/2) No footnote definition found for label: 'a' [myst.footnote] | ||
. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this produced additional docutils warnings, before the fix (https://github.com/executablebooks/MyST-Parser/pull/931/files#r1598103576)
ah well, if you haven't noticed this the same for every "inline" warning in sphinx/docutils (for both restructuredtext and myst)
these are all from docutils, not myst do you have a minimal working example, that could get the test to produce these errors |
Sorry, don't have time to minimize it, but it's coming from Quansight-Labs/ndindex#136, commit 09541959137694579060a6c48b3e429fa8e30026
|
It's possible it's coming from the other cross-reference in the same paragraph. I had to use a workaround to cross-reference cross-page footnotes. These errors all came from me splitting a document into multiple pages and forgetting to move the footnotes. |
Footnotes are now parsed similar to the corresponding restructuredtext, in that resolution (between definitions and references) and ordering is now deferred to transforms on the doctree.
This allows for the proper interaction with other docutils/sphinx transforms, including those that perform translations.
In addition, an upstream improvement to unreferenced footnote definitions is also added here: sphinx-doc/sphinx#12730, so that unreferenced and duplicate definitions are correctly warned about, e.g.:
It is of note that warnings for references with no corresponding definitions are deferred to docutils to handle, e.g. for
[^a]
with no definition:These warning messages are a little obscure, and it would be ideal that one clear warning was emitted for the issue.
However, it is non-trivial in this extension; to both suppress the existing warnings, and then replace them with a better one,
so for now we don't do it here, and ideally this would be improved upstream in docutils.
closes #930
closes #884
closes #801
closes #445