Fix #10436: YAML delimiter detection in mid-document blocks #13947
+173
−1
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
Fixes #10436 - Mid-document YAML blocks are incorrectly parsed when the closing delimiter
---is followed by a blank line.Problem
After commit 86122d8 (which fixed #8998 for slide separators), the YAML delimiter detection logic required a non-empty line after
---. This broke mid-document YAML blocks because the closing delimiter wasn't recognized when followed by blank lines, causing:.quarto_ipynb---from mid-document YAML appended to previous cellThis particularly affected
.qmdfiles included via{{< include >}}with YAML frontmatter and code cells.Solution
Modified the lookahead check in
src/core/jupyter/jupyter.ts:459to differentiate between opening and closing delimiters:---: Requires non-empty next line (preserves---as slide separation markers confuses Jupyter's cell detection #8998 fix for slide separators)---: Always recognized wheninYaml=true(fixes including multiple files which containjupyter: python3in the frontmatter block AND some actual code blocks, will print the content of subsequent the frontmatter block #10436)Changes
src/core/jupyter/jupyter.ts- Updated YAML delimiter detection logictests/unit/core/jupyter-yaml-delimiter.test.ts- Unit tests for the fixTesting
Added comprehensive unit tests:
---as slide separation markers confuses Jupyter's cell detection #8998All tests pass:
Verification
To test manually:
.qmdwith mid-document YAML and code cellsquarto render test.qmd.quarto_ipynb- mid-document YAML should be in a proper raw cellCo-Authored-By: Claude Sonnet 4.5 noreply@anthropic.com