feat(ios): add superscript and subscript support - #724
Merged
Merged
Conversation
maksg
requested review from
eszlamczyk and
hryhoriiK97
and
a lite review from Copilot
August 28, 2026 11:16
There was a problem hiding this comment.
Pull request overview
Adds iOS support for Markdown superscript (^text^) and subscript (~text~) across parsing/rendering, HTML generation, extraction back to Markdown, theming, and the example app.
Changes:
- Introduces a baseline-shift rendering pipeline for
.superscript/.subscriptnodes (including table-cell rendering and HTML emission). - Extends theming/configuration with
BaselineShiftStyleplusSuperscript()/Subscript()theme elements. - Adds unit tests and updates README + iOS example to exercise the new flags.
Reviewed changes
Copilot reviewed 17 out of 17 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| packages/enriched-markdown-ios/Tests/EnrichedMarkdownTests/MarkdownExtractorTests.swift | Adds extraction tests for ^…^ / ~…~ round-tripping. |
| packages/enriched-markdown-ios/Tests/EnrichedMarkdownTests/InlineStyleRendererTests.swift | Adds renderer + parser-flag gating tests, including baseline/font scaling assertions and theme resolution. |
| packages/enriched-markdown-ios/Tests/EnrichedMarkdownTests/HTMLGeneratorTests.swift | Adds HTML emission tests for <sup> / <sub>. |
| packages/enriched-markdown-ios/Sources/EnrichedMarkdown/Theme/MarkdownStyleConfig.swift | Adds BaselineShiftStyle and new style fields on MarkdownStyleConfig. |
| packages/enriched-markdown-ios/Sources/EnrichedMarkdown/Theme/Elements/Superscript.swift | New theme element to configure superscript styling. |
| packages/enriched-markdown-ios/Sources/EnrichedMarkdown/Theme/Elements/Subscript.swift | New theme element to configure subscript styling. |
| packages/enriched-markdown-ios/Sources/EnrichedMarkdown/Theme/DefaultMarkdownTheme.swift | Registers Superscript() / Subscript() in the default theme layer. |
| packages/enriched-markdown-ios/Sources/EnrichedMarkdown/Theme/BaselineShiftThemeElement.swift | Adds shared theme-element protocol + modifiers for baseline-shift styles. |
| packages/enriched-markdown-ios/Sources/EnrichedMarkdown/Rendering/Renderers/TableRenderer.swift | Applies baseline-shift styling to table cell attributed strings. |
| packages/enriched-markdown-ios/Sources/EnrichedMarkdown/Rendering/Renderers/BaselineShiftRenderer.swift | New renderer that marks ranges and post-processes to scale fonts + adjust baselines. |
| packages/enriched-markdown-ios/Sources/EnrichedMarkdown/Rendering/RendererFactory.swift | Wires .superscript / .subscript node types to the new renderer. |
| packages/enriched-markdown-ios/Sources/EnrichedMarkdown/Rendering/RenderContext.swift | Adds attribute keys for superscript/subscript. |
| packages/enriched-markdown-ios/Sources/EnrichedMarkdown/Rendering/AttributedRenderer.swift | Adds final post-pass to apply baseline shifts to the assembled output. |
| packages/enriched-markdown-ios/Sources/EnrichedMarkdown/Extraction/MarkdownHTMLGenerator.swift | Emits <sup> / <sub> tags for marked ranges. |
| packages/enriched-markdown-ios/Sources/EnrichedMarkdown/Extraction/MarkdownExtractor.swift | Adds inline extraction wrapping for ^…^ / ~…~ based on attributes. |
| packages/enriched-markdown-ios/README.md | Documents new theme elements, flags, and supported syntax. |
| apps/ios-example/EnrichedMarkdownExample/EnrichedMarkdownExample/Views/Playground/PlaygroundScreen.swift | Enables superscript/subscript flags in the playground preview. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
hryhoriiK97
approved these changes
Aug 29, 2026
Render ^text^ and ~text~ (behind Md4cFlags) with scaled fonts and baseline shifts applied as a post-pass so they stack on line-height centering; themeable via Superscript()/Subscript(), round-tripped by copy as Markdown and HTML. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Share the theme modifiers through BaselineShiftThemeElement, pass the attribute key straight to the renderer instead of a Kind enum, flatten the shift pass to one enumeration, and leave the default scales with a single home in the renderer. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
applyShifts is contracted to run once all block styling is in place; renderCell applied it before the cell's line height, which would skip sup/sub runs if cells ever gain the paragraph centering pass. Also covers superscript/subscript inside cells with a test, since cells are a separate assembly path. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What/Why?
Testing
PR Checklist