Skip to content

feat(markdown): let preprocessors opt out of code-block chrome - #63

Merged
phil-scott-78 merged 1 commit into
mainfrom
feat/preprocessor-skip-chrome
Jul 7, 2026
Merged

phil-scott-78 merged 1 commit into
mainfrom
feat/preprocessor-skip-chrome

Conversation

@phil-scott-78

Copy link
Copy Markdown
Contributor

Summary

  • Adds a SkipChrome flag to CodeBlockPreprocessResult, pairing with the existing SkipTransform. When set, CodeBlockRenderingService.Render returns the preprocessor''s HTML verbatim instead of wrapping it in the standard chrome (code-highlight-wrapper, standalone-code-container, the codeblock-head language bar, data-language).
  • Motivation: preprocessors whose output is not a code block — for example a fence rendered to an inline SVG diagram — currently get a language label bar around the graphic, and the wrapper''s data-language attribute causes HtmlToMarkdownConverter to reconstruct a garbage code fence from the markup in the per-page Markdown twins and Book composition. With SkipChrome, the preprocessor owns the entire output and the converter treats it as ordinary markup.
  • Documents both result flags in the "Add a custom fence syntax" how-to.

Test plan

  • New Render_SkipChrome_EmitsPreprocessorHtmlUnwrapped covers the direct Render path (the Razor <CodeBlock> entry point) with an exact-match assertion — no wrapper markup at all.
  • New SkipChrome_OmitsCodeBlockWrapper covers the Markdig pipeline path, asserting no code-highlight-wrapper, codeblock-head, or data-language in the rendered page.
  • dotnet test on the two code-block test classes: 13/13 pass.

A CodeBlockPreprocessResult can now set SkipChrome to emit its HTML
verbatim, with none of the standard wrapper markup (code-highlight-wrapper,
language head bar, container divs). This serves preprocessors whose output
is not a code block at all — a rendered diagram, a chart, a widget — which
previously got a language label bar and, via the wrapper''s data-language
attribute, were mangled back into a fake code fence by the HTML-to-markdown
converter in the per-page Markdown twins and Book composition.
@github-actions

github-actions Bot commented Jul 7, 2026

Copy link
Copy Markdown

🛰️ Docs preview: https://pr-63.pennington-dev.pages.dev

Rebuilt on every push to this PR; torn down when it closes.

@phil-scott-78
phil-scott-78 merged commit 1c1d721 into main Jul 7, 2026
4 checks passed
@phil-scott-78
phil-scott-78 deleted the feat/preprocessor-skip-chrome branch July 7, 2026 13:18
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.

1 participant