Skip to content

fix: render superscript/subscript as <sup>/<sub> instead of <em>#92

Merged
Princesseuh merged 7 commits into
bruits:mainfrom
morinokami:fix-superscript-subscript
Jun 15, 2026
Merged

fix: render superscript/subscript as <sup>/<sub> instead of <em>#92
Princesseuh merged 7 commits into
bruits:mainfrom
morinokami:fix-superscript-subscript

Conversation

@morinokami

Copy link
Copy Markdown
Contributor

Sätteri documents features.superscript / features.subscript as rendering ^text^<sup>text</sup> and ~text~<sub>text</sub>(Features docs). The options are accepted and the delimiters are consumed, but the output is wrong:

const source = '^text^ ~text~';

const { html } = markdownToHtml(source, {
  features: {
    superscript: true,
    subscript: true,
  },
});

console.log(html);
// expected: <p><sup>text</sup> <sub>text</sub></p>
// got: <p><em>text</em> <em>text</em></p>

Reproduction: https://stackblitz.com/edit/stackblitz-starters-mdzjlalh?file=index.js

This PR adds dedicated Superscript (33) and Subscript (34) MDAST node types.

Note

Same class of problem as #86 (headingAttributes): a documented feature flag that is accepted and consumes its syntax, but silently drops the result. This PR fixes the superscript/subscript case only; #86 remains open.

@codspeed-hq

codspeed-hq Bot commented Jun 15, 2026

Copy link
Copy Markdown

Merging this PR will not alter performance

✅ 24 untouched benchmarks
⏩ 8 skipped benchmarks1


Comparing morinokami:fix-superscript-subscript (29e6c41) with main (efba0de)

Open in CodSpeed

Footnotes

  1. 8 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports.

@Princesseuh Princesseuh left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great, awesome work!

@Princesseuh Princesseuh merged commit 6bcdf06 into bruits:main Jun 15, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants