Skip to content

Add superscript and subscript span extensions#310

Closed
hryhoriiK97 wants to merge 4 commits intomity:masterfrom
hryhoriiK97:feature/superscript-subscript
Closed

Add superscript and subscript span extensions#310
hryhoriiK97 wants to merge 4 commits intomity:masterfrom
hryhoriiK97:feature/superscript-subscript

Conversation

@hryhoriiK97
Copy link
Copy Markdown
Contributor

@hryhoriiK97 hryhoriiK97 commented May 1, 2026

Summary

This PR adds two opt-in inline span extensions to MD4C.

The new syntaxes are:

x^2^    (superscript)
H~2~O   (subscript)

When MD_FLAG_SUPERSCRIPTS is enabled, MD4C emits a new MD_SPAN_SUPERSCRIPT
span. When MD_FLAG_SUBSCRIPTS is enabled, MD4C emits a new MD_SPAN_SUBSCRIPT
span. The bundled HTML renderer outputs them as:

x<sup>2</sup>
H<sub>2</sub>O

md2html gets two new options: --fsuperscripts and --fsubscripts.

When MD_FLAG_SUBSCRIPTS and MD_FLAG_STRIKETHROUGH are both active, ~text~
renders as subscript and ~~text~~ remains strikethrough, preserving GFM
compatibility.

A 600-second OSS-Fuzz run found no crashes or assertion failures.

These extensions will be used in react-native-enriched-markdown.

@codecov
Copy link
Copy Markdown

codecov Bot commented May 1, 2026

Codecov Report

❌ Patch coverage is 83.09859% with 12 lines in your changes missing coverage. Please review.
✅ Project coverage is 78.98%. Comparing base (347b528) to head (5baf679).

Files with missing lines Patch % Lines
src/md4c.c 81.53% 0 Missing and 12 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master     #310      +/-   ##
==========================================
+ Coverage   78.94%   78.98%   +0.03%     
==========================================
  Files           5        5              
  Lines        3401     3464      +63     
  Branches     1138     1167      +29     
==========================================
+ Hits         2685     2736      +51     
  Misses        275      275              
- Partials      441      453      +12     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@mity
Copy link
Copy Markdown
Owner

mity commented May 4, 2026

Rebased and merged into master branch manually.

@mity mity closed this May 4, 2026
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.

2 participants