Single + in superscript or subscript #667

Open
opened 2026-01-29 14:42:33 +00:00 by claunia · 1 comment
Owner

Originally created by @geoffreymcgill on GitHub (Apr 16, 2024).

We ran into a very specific scenario using a + in superscript or subscript that appears to fail parsing correctly.

Sample 1

Superscript^+^ or Subscript~+~

The above renders as...

Screen Shot 2024-04-16 at 11 09 26 AM

Sample 2

If a space is added before the ^+^, then it parses correctly:

Superscript ^+^ or Subscript ~+~

The above renders as...

Screen Shot 2024-04-16 at 11 09 35 AM

Sample 3

Interestingly, using ^+^ also fails:

Superscript^+^ or Subscript~+~

The above renders as...

Screen Shot 2024-04-16 at 11 09 40 AM

The parsing issue only happens when using a single + char. If revised to a - char, then the subscript and subscript parse and render correctly.

Can anyone else reproduce?

Hope this helps.

Originally created by @geoffreymcgill on GitHub (Apr 16, 2024). We ran into a very specific scenario using a `+` in superscript or subscript that appears to fail parsing correctly. ### Sample 1 ```md Superscript^+^ or Subscript~+~ ``` The above renders as... <img width="282" alt="Screen Shot 2024-04-16 at 11 09 26 AM" src="https://github.com/xoofx/markdig/assets/62210/a22c34f0-cb60-4ad9-bf77-c7dbca6a65b9"> ### Sample 2 If a space is added before the `^+^`, then it parses correctly: ```md Superscript ^+^ or Subscript ~+~ ``` The above renders as... <img width="270" alt="Screen Shot 2024-04-16 at 11 09 35 AM" src="https://github.com/xoofx/markdig/assets/62210/68cff6fa-e975-4bf6-97f4-9e7bbb1fb252"> ### Sample 3 Interestingly, using `^&plus;^` also fails: ``` Superscript^&plus;^ or Subscript~&plus;~ ``` The above renders as... <img width="279" alt="Screen Shot 2024-04-16 at 11 09 40 AM" src="https://github.com/xoofx/markdig/assets/62210/ac195768-93c5-40e0-bbc4-0bdd5e338fbd"> --- The parsing issue only happens when using a single `+` char. If revised to a `-` char, then the subscript and subscript parse and render correctly. Can anyone else reproduce? Hope this helps.
claunia added the bug label 2026-01-29 14:42:33 +00:00
Author
Owner

@xoofx commented on GitHub (Jun 14, 2024):

It is reproduced here

I would believe it is a bug but don't have personal time dedicated to fix it, so PR welcome if someone is motivated. Not entirely sure that the fix is easy, as the parsing of the matching opening/closing super/sub scripts might be reusing the same rules that we use for bold/italic, and these rules are quite strict (e.g need a space before and after the opening/closing braces)

@xoofx commented on GitHub (Jun 14, 2024): It is reproduced [here](https://babelmark.github.io/?text=Superscript%5E%2B%5E+or+Subscript+~%2B~%0A) I would believe it is a bug but don't have personal time dedicated to fix it, so PR welcome if someone is motivated. Not entirely sure that the fix is easy, as the parsing of the matching opening/closing super/sub scripts might be reusing the same rules that we use for bold/italic, and these rules are quite strict (e.g need a space before and after the opening/closing braces)
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/markdig#667