Skip to content

Fix multi-line subtitle escaping its CSS class in HTML output#14043

Merged
cscheid merged 2 commits intomainfrom
fix/issue-13827
Feb 17, 2026
Merged

Fix multi-line subtitle escaping its CSS class in HTML output#14043
cscheid merged 2 commits intomainfrom
fix/issue-13827

Conversation

@cderv
Copy link
Collaborator

@cderv cderv commented Feb 16, 2026

When subtitle uses a YAML literal block scalar (|), the content escapes the .subtitle CSS 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

  1. YAML | values are parsed by Pandoc as MetaBlocks containing Para elements — even for single-line content, since | always appends a trailing newline
  2. Title-block templates wrap $subtitle$ in <p class="subtitle">$subtitle$</p>. When $subtitle$ is MetaBlocks, Pandoc renders it as <p>...</p>, producing nested <p> tags — invalid HTML5
  3. Any HTML5-compliant parser (browser or Quarto's deno-dom post-processing) auto-closes the outer <p> when it encounters the inner <p>, so content escapes the .subtitle class

Single-line values (no |) produce MetaInlines and render correctly since there's no <p> wrapping.

Fix

A normalize filter converts MetaBlocks to MetaInlines for the subtitle field using the existing quarto.utils.as_inlines() API, which calls pandoc.utils.blocks_to_inlines() internally. The conversion is surgical — only subtitle is converted. Fields like abstract and description stay as blocks since they're placed in <div> containers where block-level content is valid.

For multi-paragraph | values, blocks_to_inlines joins paragraphs with LineBreak separators, 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.lua for all output formats, though the nested <p> bug only manifests in formats whose templates wrap these fields in <p> elements.

Fixes #13827

cderv and others added 2 commits February 16, 2026 17:35
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>
@posit-snyk-bot
Copy link
Collaborator

posit-snyk-bot commented Feb 16, 2026

Snyk checks have passed. No issues have been found so far.

Status Scanner Critical High Medium Low Total (0)
Open Source Security 0 0 0 0 0 issues
Licenses 0 0 0 0 0 issues

💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse.

@cscheid cscheid merged commit fd74e00 into main Feb 17, 2026
91 of 93 checks passed
@cscheid cscheid deleted the fix/issue-13827 branch February 17, 2026 15:39
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.

multi-line subtitle is rendered outside the subtitle class

3 participants

Comments