Skip to content

Conversation

@elijahgreenstein
Copy link

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.

elijahgreenstein and others added 5 commits August 27, 2025 20:56
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.
@minchinweb
Copy link

Any chance of this being merged soon? I'd like to use it for my projects...

Copy link
Contributor

@KyleKing KyleKing left a 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 👍🏻

Comment on lines 36 to 37
UNESCAPE_RE = re.compile(r"\\([ \\!\"#$%&'()*+,./:;<=>?@[\]^_`{|}~-])")
WHITESPACE_RE = re.compile(r"(^|[^\\])(\\\\)*\s")
Copy link
Contributor

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?

https://github.com/elijahgreenstein/mdit-py-plugins/blob/e2fb671b3a66e86690239137429d5ef69f5e06d5/mdit_py_plugins/subscript/__init__.py#L25-L26

Copy link
Author

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.

elijahgreenstein and others added 5 commits January 16, 2026 10:27
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.
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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants