Render Markdig MathInline and MathBlock nodes#145
Conversation
boxofyellow
left a comment
There was a problem hiding this comment.
@copilot please check out this comment.
boxofyellow
left a comment
There was a problem hiding this comment.
@copilot This PR need to be rebased (not just having master merged on top). However you will not have permission to forcepush changes.
Please checkout the main branch, create a new branch and then replay this PRs commits onto top of that new branch while addressing conflicts.
When you are done please let me know the name of the new branch you created.
Co-authored-by: boxofyellow <54955040+boxofyellow@users.noreply.github.com>
Co-authored-by: boxofyellow <54955040+boxofyellow@users.noreply.github.com>
Done. The rebased branch is Resolved conflicts:
All 167 unit tests ( |
7b43580 to
f370c11
Compare
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #145 +/- ##
==========================================
+ Coverage 95.81% 95.92% +0.11%
==========================================
Files 30 31 +1
Lines 1696 1743 +47
Branches 179 182 +3
==========================================
+ Hits 1625 1672 +47
Misses 46 46
Partials 25 25 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Co-authored-by: boxofyellow <54955040+boxofyellow@users.noreply.github.com>
UseAdvancedExtensions()enables Markdig's mathematics extension, which parses$...$intoMathInlineand$$...$$intoMathBlock. Neither type had a registeredConsoleObjectRenderer, so all math content was silently dropped — leaving unexplained gaps in any document containing math.Renderers
ConsoleMathInlineRenderer(one-liner inConsoleObjectRenderers.cs) wrapsMathInline.Contentwith theDisplayOptions.MathInlinestyle, mirroringConsoleCodeInlineRenderer.ConsoleMathBlockRenderer(dedicated file) uses a fenced presentation likeConsoleCodeBlockRenderer, withDisplayOptions.MathBlockand an optionalmathlabel gated onShowMathBlockLabel.Registration order
MathBlockextendsFencedCodeBlock, and Markdig'sMarkdownObjectRenderer.Acceptuses type assignability — soConsoleMathBlockRenderermust precedeConsoleCodeBlockRendererin the list, otherwise the code-block renderer would claim the type. A comment inConsoleRenderer.csrecords this.DisplayOptions
New properties (with
Clone()updates):MathInline,MathBlock— text styles (defaultgreen on purpleto differentiate fromCodeInLine/CodeBlock'syellow on blue).ShowMathBlockLabel(defaultfalse),MathBlockLabel,MathBlockLabelText("math") — opt-in language-style label, analogous toShowFencedCodeBlockInfo/FencedCodeBlockInfo.Tests / fixtures
mathInline.md/.txtandmathBlock.md/.txtsnapshot pairs.RendererTests_MathInlineTestandRendererTests_MathBlockTestwith[DataRow]for default + crazy styles.m_crazyOptionsextended with the new properties (incl.ShowMathBlockLabel = true).bracketEscaping.mdextended with$[test30]…$and$$[test31]…$$;bracketEscaping.txtregenerated.Docs / example
example.md: new## Mathematicssection and Mathematics TODO entry.CHANGELOG.md: entry under Upcoming Changes → Renderers.