Fix multi-line subtitle escaping its CSS class in HTML output#14043
Merged
Fix multi-line subtitle escaping its CSS class in HTML output#14043
Conversation
Convert MetaBlocks to MetaInlines for subtitle field in normalize.lua, preventing nested <p> tags (invalid HTML5) when YAML uses literal block scalar (|). Fixes #13827 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Exercises the MetaBlocks-with-multiple-Para path where blocks_to_inlines joins paragraphs with LineBreak separators. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Collaborator
✅ Snyk checks have passed. No issues have been found so far.
💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse. |
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.
When
subtitleuses a YAML literal block scalar (|), the content escapes the.subtitleCSS class in HTML and RevealJS output. The<p class="subtitle">element ends up empty, with content rendered as sibling<p>tags outside the styled wrapper.Root Cause
|values are parsed by Pandoc asMetaBlockscontainingParaelements — even for single-line content, since|always appends a trailing newline$subtitle$in<p class="subtitle">$subtitle$</p>. When$subtitle$isMetaBlocks, Pandoc renders it as<p>...</p>, producing nested<p>tags — invalid HTML5<p>when it encounters the inner<p>, so content escapes the.subtitleclassSingle-line values (no
|) produceMetaInlinesand render correctly since there's no<p>wrapping.Fix
A normalize filter converts
MetaBlockstoMetaInlinesfor thesubtitlefield using the existingquarto.utils.as_inlines()API, which callspandoc.utils.blocks_to_inlines()internally. The conversion is surgical — onlysubtitleis converted. Fields likeabstractanddescriptionstay as blocks since they're placed in<div>containers where block-level content is valid.For multi-paragraph
|values,blocks_to_inlinesjoins paragraphs withLineBreakseparators, rendering as<br>in HTML. This preserves the newline semantics of|(a folded scalar>would be used to collapse newlines).The fix runs in
normalize.luafor all output formats, though the nested<p>bug only manifests in formats whose templates wrap these fields in<p>elements.Fixes #13827