Skip to content

Superscript and Subscript rendering using symbols#107

Merged
Byron merged 3 commits intoByron:mainfrom
kinnison:super-sub-not-html
Dec 23, 2025
Merged

Superscript and Subscript rendering using symbols#107
Byron merged 3 commits intoByron:mainfrom
kinnison:super-sub-not-html

Conversation

@kinnison
Copy link
Contributor

pulldown-cmark can parse ^superscript^ and ~subscript~ and in order to be able to roundtrip that kind of thing, I thought it would be good to add an option to permit the use of ^ and ~ rather than <sup> and <sub>.

This is my first time touching this project so please let me know if I've done anything awful, or if you need me to fix up my commit messages to fit your process more.

Copy link
Owner

@Byron Byron left a comment

Choose a reason for hiding this comment

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

Thanks a lot for contributing, it's much appreciated!

Everything looks good actually, and the test is particularly good to have. However, I'd just need a little tweak beyond my other comment:

  • The first commit must be feat!: … to indicate a breaking change due to the new struct field. That should also be mentioned in the commit message then so people know what exactly is breaking there.
  • Please remove the tests: prefix, there is no need for this to go into the changelog.

Thanks again!

@kinnison
Copy link
Contributor Author

Thank you for the review - I shall make those changes tonight when I'm home.

@Byron
Copy link
Owner

Byron commented Dec 22, 2025

Thanks a lot! I also recommend rebasing as I have added full docs to be a better example for future contributions 😅.

@kinnison
Copy link
Contributor Author

Thanks a lot!

No worries, I always try my best to be a good citizen.

I also recommend rebasing as I have added full docs to be a better example for future contributions 😅.

Oooh fancy. I shall be sure to do so, thank you.

Superscript and subscript can be presented in markdown as:
^superscript^ and ~subscript~ respectively. This is not always turned on,
and many people prefer the HTML tag form, however in order to round-trip
markdown which uses the symbolic form we need an option to enable that.

This feature is enabled via a new field in the `Options` struct.

Signed-off-by: Daniel Silverstone <dsilvers@digital-scurf.org>
Signed-off-by: Daniel Silverstone <dsilvers@digital-scurf.org>
@kinnison
Copy link
Contributor Author

I have rebased, added the doccomment, and updated the commit messages.

I hope that's what you were after - if I've missed anything, please just yell.

@Byron
Copy link
Owner

Byron commented Dec 23, 2025

Thanks for your help! I think that's it and I will create a new release right after merging.

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR adds support for rendering superscript and subscript using symbolic notation (^ and ~) instead of HTML tags (<sup> and <sub>), enabling byte-for-byte round-tripping of markdown documents that use pulldown-cmark's ENABLE_SUPERSCRIPT and ENABLE_SUBSCRIPT options.

  • Adds a new use_html_for_super_sub_script boolean option to control rendering format (defaults to true for backward compatibility)
  • Updates rendering logic to output ^ and ~ symbols when the option is set to false
  • Provides example usage through the stupicat tool with the STUPICAT_SUB_SUPER_SYMBOLIC environment variable

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
src/lib.rs Adds the use_html_for_super_sub_script option to the Options struct and updates superscript/subscript rendering logic in both start and end tag handlers
examples/stupicat.rs Updates to use cmark_with_options and cmark_resume_with_options, adding support for the STUPICAT_SUB_SUPER_SYMBOLIC environment variable
tests/cat.sh Adds integration test for symbolic super/subscript rendering
tests/fixtures/symbolic-super-sub-script.md Test input file with symbolic notation for super/subscript
tests/fixtures/snapshots/stupicat-symbolic-super-sub-script-output Expected output snapshot for the symbolic notation test

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@Byron Byron force-pushed the super-sub-not-html branch from da3c701 to e2211a9 Compare December 23, 2025 04:07
- adjust doc-string links and phrasing.
@Byron Byron force-pushed the super-sub-not-html branch from e2211a9 to aba929c Compare December 23, 2025 04:08
@Byron Byron merged commit 15e7a74 into Byron:main Dec 23, 2025
2 checks passed
@Byron
Copy link
Owner

Byron commented Dec 23, 2025

And here it is: https://github.com/Byron/pulldown-cmark-to-cmark/releases/tag/v22.0.0

@kinnison kinnison deleted the super-sub-not-html branch December 23, 2025 08:56
@kinnison
Copy link
Contributor Author

And I can update my crate to use this release and all the tests still pass -- thank you so much @Byron

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