Skip to content

Fix nested fenced code block parsing - #722

Merged
wesm merged 2 commits into
mainfrom
delicate-lever
Jun 17, 2026
Merged

Fix nested fenced code block parsing#722
wesm merged 2 commits into
mainfrom
delicate-lever

Conversation

@wesm

@wesm wesm commented Jun 17, 2026

Copy link
Copy Markdown
Member

Replaces the lazy fenced-code regex in transcript parsing with a scanner that tracks the opening backtick fence length, so shorter nested fences remain inside the outer code block.

Adds a regression case for a markdown fence containing a nested qmd fence.

Fixes #721.

@roborev-ci

roborev-ci Bot commented Jun 17, 2026

Copy link
Copy Markdown

roborev: Combined Review (7d374e3)

Medium issue found in the fenced code parsing change.

Medium

  • frontend/src/lib/utils/content-parser.ts:210 - closingFence treats any backtick run at least as long as the opener as the closing fence, even when it appears inline or has non-whitespace text after it. This can prematurely end a fenced code segment when the code contains a string/comment with ``` or ```` before the real closing fence, causing the rest of the code to be parsed as normal text or tool/thinking blocks.
    • Fix: Only accept closing fences at a valid fence line start with up to three leading spaces and only spaces/tabs after the backticks. Add regression coverage for same-length backtick runs inside code content.

Panel: ci_default_security | Synthesis: codex, 10s | Members: codex_default (codex/default, done, 2m23s), codex_security (codex/security, done, 1m0s) | Total: 3m33s

@roborev-ci

roborev-ci Bot commented Jun 17, 2026

Copy link
Copy Markdown

roborev: Combined Review (80f01ae)

No issues found.


Panel: ci_default_security | Synthesis: codex | Members: codex_default (codex/default, done, 4m50s), codex_security (codex/security, done, 1m25s) | Total: 6m15s

@wesm
wesm merged commit 546db04 into main Jun 17, 2026
21 checks passed
@wesm
wesm deleted the delicate-lever branch June 17, 2026 15:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

Code block in session transcript breaks when its body contains a nested code fence

1 participant