Skip to content

feat(ios): add superscript and subscript support - #724

Merged
maksg merged 4 commits into
mainfrom
ios-supsub
Aug 31, 2026
Merged

feat(ios): add superscript and subscript support#724
maksg merged 4 commits into
mainfrom
ios-supsub

Conversation

@maksg

@maksg maksg commented Aug 28, 2026

Copy link
Copy Markdown
Collaborator

What/Why?

Testing

PR Checklist

  • Code compiles and runs on iOS
  • Code compiles and runs on Android
  • Updated documentation/README if applicable
  • Ran example app to verify changes
  • E2E tests are passing
  • Required E2E tests have been added (if applicable)

@maksg
maksg requested review from eszlamczyk and hryhoriiK97 and a lite review from Copilot August 28, 2026 11:16

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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 / .subscript nodes (including table-cell rendering and HTML emission).
  • Extends theming/configuration with BaselineShiftStyle plus Superscript() / 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.

Copilot AI review requested due to automatic review settings August 28, 2026 13:16

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

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

maksg and others added 4 commits August 31, 2026 11:50
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>
@maksg
maksg merged commit 6fa6d08 into main Aug 31, 2026
12 checks passed
@maksg
maksg deleted the ios-supsub branch August 31, 2026 11:40
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