fix: preserve line breaks in YAML code blocks (#1463)#1529
fix: preserve line breaks in YAML code blocks (#1463)#1529franksong2702 wants to merge 1 commit intonesquena:masterfrom
Conversation
Prism's YAML tokenizer wraps tokens in spans that can collapse newlines via display:inline-block. Force white-space:pre on language-yaml code blocks and their .token children so multi-line YAML renders with correct line breaks. Only language-yaml is affected — bash and other languages already render correctly.
|
Thanks @franksong2702 — this is the same diagnosis as #1516 with one extra detail (the Two PRs are now open against #1463 — this one and #1516, both yours. Going to consolidate so we don't double-merge:
The If you'd rather merge the slightly tighter selector here, happy to swap which is the canonical PR — just flag it. Otherwise I'll close this in favor of #1516 in the next release pass. |
|
Closing this as superseded by #1516 — both target the YAML newline collapse caused by Prism's token spans, but #1516 also covers the markdown preview panel ( The selector-grouping refinement in this PR (combining Routing #1516 through the next merge batch. Thanks for both — and for the careful diagnostic write-up. YAML rendering correctly is going to make a noticeable difference for everyone who pastes config files into chat. |
…sorbed CHANGELOG, ROADMAP, TESTING bumped (3936 \u2192 3946). 8 constituent PRs: - nesquena#1523 (@franksong2702) branch indicator codepoint fix - nesquena#1519 (@franksong2702) onboarding API-key focus loss fix - nesquena#1518 (@franksong2702) voice-mode toggle-off recognizer stop - nesquena#1516 (@franksong2702) YAML newline CSS rules - nesquena#1517 (@franksong2702) __CACHE_VERSION__ \u2192 __WEBUI_VERSION__ rename - nesquena#1532 (@ai-ag2026) state.db WebUI session recovery - nesquena#1525 (@ai-ag2026) stale stream state proactive cleanup - nesquena#1526 (@ai-ag2026) max_tokens forwarding + OpenRouter quota classifier Opus MUST-FIX absorbed: sw.js conflict-marker cleanup + regression guard. Opus SHOULD-FIX deferred to follow-up nesquena#1533 (race in _clear_stale_stream_state). 2 closed as duplicates: nesquena#1528 (identical to nesquena#1517), nesquena#1529 (superseded by nesquena#1516). 1 maintainer-review label: nesquena#1531 (Asunfly stowaway change in force-push). 5 stay on hold: nesquena#1418 nesquena#1464 nesquena#1404 nesquena#1353 nesquena#1311.
Thinking Path
CSS-only bug surfaced during stage-276 triage. After #1400 fixed the
parse failederror for YAML code blocks, YAML rendering still appeared flattened — newlines inside fenced YAML blocks were not visible. The issue reporter ran two diagnostic probes (per maintainer guidance):pre.textContentcontains\ncharacters → renderer pipeline is not dropping newlineslanguage-bashrender correctly; onlylanguage-yamlis affectedThat combination rules out the renderer pipeline, the
<pre>user-agent stylesheet, and the.code-tree-wrapCSS. What remains is Prism's YAML tokenizer — it wraps tokens in<span class="token ...">elements that can setdisplay:inline-block, which collapses perceived line breaks even though the raw text nodes preserve\n.What Changed
static/style.csslanguage-*background override (line ~737)Forces
white-space: preon both the<code>element and its Prism-generated<span>children, so newlines render visibly regardless of tokenizer-injecteddisplayproperties.Why It Matters
YAML is one of the most common LLM output formats (config files, docker-compose, CI pipelines, Kubernetes manifests). Flattened YAML in the chat is not just ugly — it's unreadable. Users copy-paste broken output and waste turns re-requesting formatting.
Verification
pytest tests/ -v— 3935 passed, 3 failed (pre-existing, unrelated)language-yamlis targeted —language-bash,language-json, and plain code blocks are unaffectedwhite-space: preon.tokenspans does not break single-line YAML (tokens still flow inline; only multi-line content gains visible line breaks)Risks
Very low. Single CSS selector with
!importantscoped to.msg-body pre code.language-yaml. No JavaScript changes. No behavior change for non-YAML code blocks.If Prism's YAML grammar is updated in the future to not inject
display:inline-blockon tokens, this rule becomes a harmless no-op.Follow-ups
Model Used
mimo-v2.5-pro(diagnosis + fix) +gpt-5.4-mini(worker execution)Fixes #1463