-
Notifications
You must be signed in to change notification settings - Fork 32
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
✨ NEW: Port abbr plugin (executablebooks#14) #63
base: master
Are you sure you want to change the base?
Conversation
Thanks for submitting your first pull request! You are awesome! 🤗 |
Hmm, pre-commit seems broken due to PyCQA/isort#2077? I certainly can't run it. |
Thanks @jessicah, could you perhaps add some more test cases, e.g. interaction with other syntax elements: abbr definitions in lists, abbr references in link texts, ... Looking at this now, one issue related to myst-parser I'd note, is that the extension is doing a "look-ahead" parse to find all the abbreviation definitions. ```{note}
*[HTML]: HyperText Markup Language
HTML
```
HTML Here, in MyST-Parser, the outer The "ideal" solution may be, to have the markdown-it plugin collect all the abbreviation definitions, but not do the replacement of the text. |
@chrisjsewell hmm, that's how the original plugin does the replacements, it's basically a 1:1 translation of the source, just some janky translation of their regex loop. I don't really know enough to be able to adapt to a nested parsing model; I pretty much relied on comparing an existing JS <-> Python extension... if you have some guidance, that would help! |
Codecov ReportBase: 92.67% // Head: 92.43% // Decreases project coverage by
Additional details and impacted files@@ Coverage Diff @@
## master #63 +/- ##
==========================================
- Coverage 92.67% 92.43% -0.25%
==========================================
Files 29 32 +3
Lines 1679 1784 +105
==========================================
+ Hits 1556 1649 +93
- Misses 123 135 +12
Flags with carried forward coverage won't be shown. Click here to find out more.
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. ☔ View full report at Codecov. |
I think just for now, if you could add in an option to not make the replacements (i.e. just extract the definitions). def abbr_plugin(md: MarkdownIt, replace = True):
"""Plugin ported from
`markdown-it-abbr <https://github.com/markdown-it/markdown-it-abbr>`__.
.. code-block:: md
*[HTML]: HyperText Markup Language
"""
md.block.ruler.before(
"reference", "abbr_def", abbr_def, {"alt": ["paragraph", "reference"]}
)
if replace:
md.core.ruler.after("linkify", "abbr_replace", abbr_replace) and yeh also if you can add some more tests |
No description provided.