Skip to content

Render Markdig Figure and FigureCaption blocks#142

Merged
boxofyellow merged 3 commits into
mainfrom
copilot/implement-figure-and-figurecaption-renderers
May 16, 2026
Merged

Render Markdig Figure and FigureCaption blocks#142
boxofyellow merged 3 commits into
mainfrom
copilot/implement-figure-and-figurecaption-renderers

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented May 16, 2026

Markdig's UseFigures() extension (enabled via UseAdvancedExtensions()) parses ^^^-delimited figure blocks into Figure / FigureCaption AST nodes, but no renderers were registered for them, so figures and their captions were silently dropped.

Changes

  • Renderers (ObjectRenderers/ConsoleObjectRenderers.cs):
    • ConsoleFigureRenderer — wraps children in a Style.Plain frame (mirrors ConsoleCustomContainerRenderer / ConsoleQuoteBlockRenderer).
    • ConsoleFigureCaptionRenderer — writes inline content wrapped in the new FigureCaption style.
  • Registration: Both added alphabetically in ConsoleRenderer ahead of ConsoleContainerInlineRenderer.
  • DisplayOptions.FigureCaption: new TextStyle defaulting to Italic; cloned in Clone().
  • Tests: new figure.md / figure.txt pair, RendererTests_FigureCaptionTest (default + useCrazy), m_crazyOptions extended, bracketEscaping resources extended with [test30][test32] covering caption text, bold inside captions, and image alt text inside figures.
  • Docs: new ## Figures section in example.md; changelog entry under Upcoming Changes › Renderers.
internal class ConsoleFigureCaptionRenderer : ConsoleObjectRenderer<FigureCaption>
{
    protected override void Write(ConsoleRenderer renderer, FigureCaption obj)
        => renderer
            .StartInline()
            .AddInLine($"[{renderer.Options.FigureCaption.ToSpectreStyle().ToMarkup()}]")
            .WriteLeafInline(obj)
            .AddInLine("[/]")
            .EndInline();
}

Rendered output for ^^^ caption\n![sample](url)\n^^^:

┌───────────────────────────────────────────┐
│ ┌───────────────────────────────────────┐ │
│ │ A descriptive caption for the figure. │ │
│ │ ![sample](http://example.com/img.png) │ │
│ └───────────────────────────────────────┘ │
└───────────────────────────────────────────┘

Copilot AI linked an issue May 16, 2026 that may be closed by this pull request
Copilot AI changed the title [WIP] Add rendering for Figure and FigureCaption blocks Render Markdig Figure and FigureCaption blocks May 16, 2026
Copilot AI requested a review from boxofyellow May 16, 2026 15:15
Copy link
Copy Markdown
Owner

@boxofyellow boxofyellow left a comment

Choose a reason for hiding this comment

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

@copilot please checkout these comments.

Comment thread docs/CHANGELOG.md Outdated
Comment thread docs/CHANGELOG.md Outdated
Copy link
Copy Markdown
Owner

@boxofyellow boxofyellow left a comment

Choose a reason for hiding this comment

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

@copilot Please rebase (not merge in master) this PR and address conflicts.

Copy link
Copy Markdown
Contributor Author

Copilot AI commented May 16, 2026

@copilot Please rebase (not merge in master) this PR and address conflicts.

I attempted the rebase locally (rebased cleanly onto 42efafd, resolved the conflicts with #141 in docs/CHANGELOG.md, ConsoleMarkdownRenderer.Example/data/example.md, and ConsoleMarkdownRenderer.Tests/resources/bracketEscaping.{md,txt} — renumbering my bracket test markers to [test32][test34] since #141 took [test30][test31] — and all 158 tests passed), but my push tooling only supports fast-forward pushes and rejected the rebased history with non-fast-forward. I don't have the ability to git push --force / --force-with-lease from this environment, so I can't complete the rebase on the remote. Could you either force-push the rebased branch yourself, or grant the agent permission to force-push so I can retry?

Copilot AI requested a review from boxofyellow May 16, 2026 22:45
Copilot AI and others added 3 commits May 16, 2026 19:14
Co-authored-by: boxofyellow <54955040+boxofyellow@users.noreply.github.com>
Co-authored-by: boxofyellow <54955040+boxofyellow@users.noreply.github.com>
@boxofyellow boxofyellow force-pushed the copilot/implement-figure-and-figurecaption-renderers branch from 979950f to fed8a46 Compare May 16, 2026 23:22
@boxofyellow boxofyellow marked this pull request as ready for review May 16, 2026 23:25
@codecov
Copy link
Copy Markdown

codecov Bot commented May 16, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 95.82%. Comparing base (42efafd) to head (fed8a46).

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #142      +/-   ##
==========================================
+ Coverage   95.78%   95.82%   +0.03%     
==========================================
  Files          30       30              
  Lines        1662     1676      +14     
  Branches      176      176              
==========================================
+ Hits         1592     1606      +14     
  Misses         46       46              
  Partials       24       24              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@boxofyellow boxofyellow merged commit 20f15e5 into main May 16, 2026
12 checks passed
@boxofyellow boxofyellow deleted the copilot/implement-figure-and-figurecaption-renderers branch May 16, 2026 23:27
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.

[Markdig] Consider rendering Figure and FigureCaption blocks

2 participants