Skip to content
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

extras: Allow superscript to begin with plus, minus, or single quote #31

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

jmooring
Copy link
Member

@jmooring jmooring commented Dec 23, 2024

Closes #30

In my view an upstream change that would help us is unlikely. This is admittedly a trick, but it is (a) isolated to superscript parsing, and (b) only applicable to the plus, minus, and single quote symbols.

The goldmark parser.ScanDelimiter function receives the line, but doesn't pass it on to anything else. So all we're doing is replacing the plus, minus, or single quote symbol with the letter "z" if the symbol is the first character after the delimiter. Using the letter "z" was an arbitrary choice.

I included the plus sign because it is common in chemistry, and I include the single quote because it is common in math.


Other common superscripts include the registered trademark, trademark, and service mark symbols, but their Unicode representations are already superscript-y (e.g., Hugo®, Hugo™, Hugo ℠).

@jmooring jmooring force-pushed the superscript-punctuation-30 branch from 33c0e92 to 8cef28b Compare December 23, 2024 06:25
@bep
Copy link
Member

bep commented Dec 23, 2024

I don't have a strong opinion on this, but the code looks correct. I don't mind having small hacks like these if the cause is .. nobel enough; and I guess not having negative exponents is making the superscript feature ... less than useful.

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.

Negative superscripts do not work
2 participants