✨ NEW: Port abbr plugin (executablebooks#14)#63
✨ NEW: Port abbr plugin (executablebooks#14)#63jessicah wants to merge 2 commits intoexecutablebooks:masterfrom
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
```
HTMLHere, 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 Report❌ Patch coverage is
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. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
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.