-
Notifications
You must be signed in to change notification settings - Fork 36
✨ NEW: Add superscript plugin and tests #128
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
base: master
Are you sure you want to change the base?
✨ NEW: Add superscript plugin and tests #128
Conversation
Plugin ported from https://github.com/markdown-it/markdown-it-sup
Fixtures file is copied from the `markdown-it-sup` tests: https://github.com/markdown-it/markdown-it-sup/blob/master/test/fixtures/sup.txt Test is modelled on other Markdown-It-Py inline tests.
Also, remove superscript (and subscript) from list of plugins to port.
for more information, see https://pre-commit.ci
|
Any chance of this being merged soon? I'd like to use it for my projects... |
KyleKing
left a comment
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.
Looks just like the JS version, thank you!
I'm not a maintainer, so I don't know if my review will help close this, but it can't hurt 👍🏻
mdit_py_plugins/superscript/index.py
Outdated
| UNESCAPE_RE = re.compile(r"\\([ \\!\"#$%&'()*+,./:;<=>?@[\]^_`{|}~-])") | ||
| WHITESPACE_RE = re.compile(r"(^|[^\\])(\\\\)*\s") |
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.
While WHITESPACE_RE is the same, I'm not sure if UNESCAPE_RE should diverge the way it does and maybe they could be standardized and extracted into a utility file?
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.
Hey there, thanks for the help cleaning up the tests! As for UNESCAPE_RE, I checked the original JS subscript plugin and the original JS superscript plugin, and it looks like the Python port of the subscript plugin here (in mdit_py_plugins) included an extra backslash in the middle of the UNESCAPE_RE string. As you suggested, I've standardized the expressions for both plugins and moved them into the existing utility file.
Co-authored-by: Kyle King <[email protected]>
Co-authored-by: Kyle King <[email protected]>
The subscript and superscript plugins both use the same regular expressions. This commit standardizes and centralizes the regex into a utility file.
for more information, see https://pre-commit.ci
My original docstring stated that superscripted text cannot contain any whitespace characters. In fact, superscripted text can contain space characters, as long as they are escaped.
Add a superscript plugin and associated tests ported from https://github.com/markdown-it/markdown-it-sup.
Update documentation with superscript plugin and remove superscript (and subscript, added in PR #122) from list of plugins to port.