Skip to content

fix(layout): superscript/subscript run types + footnote marker links (#71) - #73

Merged
sonatique merged 1 commit into
mainfrom
fix/issue-71-layout-superscript-subscript
Jun 20, 2026
Merged

fix(layout): superscript/subscript run types + footnote marker links (#71)#73
sonatique merged 1 commit into
mainfrom
fix/issue-71-layout-superscript-subscript

Conversation

@sonatique

Copy link
Copy Markdown
Owner

Fixes #71.

Problem

The AdocNet.Layout inline model had no superscript/subscript run type, so LayoutBuilder flattened ^sup^, ~sub~, and footnote markers into plain, full-size, baseline TextRuns. The Avalonia live preview (which renders from the layout model) therefore showed H₂O, E=mc², and every footnote reference as ordinary inline text — visibly wrong versus the exported HTML/PDF from the same document. This is the follow-on to #63 (footnotes no longer inlined as body text, but the [1] was still plain).

Fix

  1. New run typesSuperscriptRun and SubscriptRun (wrapper-with-Children, like BoldRun/ItalicRun).
  2. LayoutBuilder maps SuperscriptInlineNode/SubscriptInlineNode to them, and a FootnoteInlineNode to a superscript marker that is also a link to its definition — SuperscriptRun > LinkRun > TextRun("[n]"), using the _footnotedef_N anchor convention from the HTML converter.
  3. AvaloniaRenderer renders both runs as a Span with a reduced font size and BaselineAlignment.Superscript/Subscript. LinkRun is already clickable via the LinkClicked event, so footnote markers become navigable.

Design notes

  • Body font size is untouched. Setting explicit FontSize on body TextBlocks would override the host container's font inheritance (a regression risk for AdocForge). Body keeps inheriting; the new AvaloniaRenderTheme.BodyFontSize (default 14) is the reference size used only to scale super/subscript — a host with a non-default body size sets that knob to match.
  • Navigation. The marker's link href follows the #_footnotedef_N convention so a host can navigate to the note via LinkClicked (the same way the renderer already treats every link/xref). True in-pane scroll-to-anchor stays the host's responsibility, since the layout model has no positional anchor system.

Tests

  • LayoutBuilderTests: super/subscript-run mapping and the footnote-marker-link structure (SuperscriptRun > LinkRun(Href = #_footnotedef_1) > TextRun("[1]")); its plain-text helper now recurses through wrapper runs so the existing Layout/Avalonia: footnotes inlined as bracketed body text (live-preview path), not a marker #63 footnote assertions still hold.
  • SuperscriptRenderingTests (new): the Avalonia Span geometry (reduced FontSize, BaselineAlignment.Superscript/Subscript) and the clickable footnote marker.

Full Release suite green (0 failures): Layout 48→51, Avalonia 60→63.

Related: #63 (footnote-as-body-text in this path), #64/#69 (PDF footnote superscript+link).

…71)

The AdocNet.Layout inline model had no superscript/subscript run, so
LayoutBuilder flattened ^sup^, ~sub~, and footnote markers into plain,
full-size, baseline TextRuns. The Avalonia live preview (which renders from the
layout model) therefore showed H2O, E=mc2, and every footnote reference as
ordinary inline text, diverging from the exported HTML/PDF — the follow-on to
#63.

Adds SuperscriptRun and SubscriptRun (wrapper-with-Children, like BoldRun) to
AdocNet.Layout. LayoutBuilder maps SuperscriptInlineNode/SubscriptInlineNode to
them, and a FootnoteInlineNode to a superscript marker that is also a link to its
definition (SuperscriptRun > LinkRun > TextRun("[n]"), using the _footnotedef_N
anchor convention from the HTML converter). AvaloniaRenderer renders both runs as
a Span with a reduced font size and BaselineAlignment.Superscript/Subscript;
LinkRun is already clickable via the LinkClicked event, so footnote markers
become navigable. Body text keeps inheriting its size from the host container;
the new AvaloniaRenderTheme.BodyFontSize is the reference size used only to scale
super/subscript.

Tests: LayoutBuilderTests gains super/subscript-run and footnote-marker-link
coverage (and its plain-text helper now recurses through wrapper runs);
SuperscriptRenderingTests verifies the Avalonia Span geometry and the clickable
footnote marker.
@sonatique
sonatique merged commit c500350 into main Jun 20, 2026
4 checks passed
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.

Layout/Avalonia: superscript/subscript (incl. footnote markers) flattened to plain text — no Superscript/Subscript run type

1 participant