feat(markdown): let preprocessors opt out of code-block chrome - #63
Merged
Merged
Conversation
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.
|
🛰️ Docs preview: https://pr-63.pennington-dev.pages.dev Rebuilt on every push to this PR; torn down when it closes. |
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.
Summary
SkipChromeflag toCodeBlockPreprocessResult, pairing with the existingSkipTransform. When set,CodeBlockRenderingService.Renderreturns the preprocessor''s HTML verbatim instead of wrapping it in the standard chrome (code-highlight-wrapper,standalone-code-container, thecodeblock-headlanguage bar,data-language).data-languageattribute causesHtmlToMarkdownConverterto reconstruct a garbage code fence from the markup in the per-page Markdown twins and Book composition. WithSkipChrome, the preprocessor owns the entire output and the converter treats it as ordinary markup.Test plan
Render_SkipChrome_EmitsPreprocessorHtmlUnwrappedcovers the directRenderpath (the Razor<CodeBlock>entry point) with an exact-match assertion — no wrapper markup at all.SkipChrome_OmitsCodeBlockWrappercovers the Markdig pipeline path, asserting nocode-highlight-wrapper,codeblock-head, ordata-languagein the rendered page.dotnet teston the two code-block test classes: 13/13 pass.