fix(layout): superscript/subscript run types + footnote marker links (#71) - #73
Merged
Merged
Conversation
…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.
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.
Fixes #71.
Problem
The
AdocNet.Layoutinline model had no superscript/subscript run type, soLayoutBuilderflattened^sup^,~sub~, and footnote markers into plain, full-size, baselineTextRuns. The Avalonia live preview (which renders from the layout model) therefore showedH₂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
SuperscriptRunandSubscriptRun(wrapper-with-Children, likeBoldRun/ItalicRun).LayoutBuildermapsSuperscriptInlineNode/SubscriptInlineNodeto them, and aFootnoteInlineNodeto a superscript marker that is also a link to its definition —SuperscriptRun > LinkRun > TextRun("[n]"), using the_footnotedef_Nanchor convention from the HTML converter.AvaloniaRendererrenders both runs as aSpanwith a reduced font size andBaselineAlignment.Superscript/Subscript.LinkRunis already clickable via theLinkClickedevent, so footnote markers become navigable.Design notes
FontSizeon body TextBlocks would override the host container's font inheritance (a regression risk for AdocForge). Body keeps inheriting; the newAvaloniaRenderTheme.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.#_footnotedef_Nconvention so a host can navigate to the note viaLinkClicked(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 AvaloniaSpangeometry (reducedFontSize,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).