Fix #10436: YAML delimiter detection in mid-document blocks#13947
Open
kompre wants to merge 3 commits intoquarto-dev:mainfrom
Open
Fix #10436: YAML delimiter detection in mid-document blocks#13947kompre wants to merge 3 commits intoquarto-dev:mainfrom
kompre wants to merge 3 commits intoquarto-dev:mainfrom
Conversation
…ng render When rendering a .qmd file that contains code cells, an intermediate .quarto_ipynb is created. During this conversion, YAML closing delimiter `---` followed by a blank line was not recognized due to the lookahead check added in commit 86122d8 (issue quarto-dev#8998). This caused cells to incorrectly gobble up markdown content until a code cell was found. The error is particularly evident with mid-document YAML blocks: the opening `---` of the mid-document YAML is incorrectly recognized as the closing delimiter of the previous cell (raw or markdown), causing the YAML content to be misparsed. The fix differentiates between opening and closing YAML delimiters: - Opening `---`: Requires non-empty next line (preserves quarto-dev#8998 fix) - Closing `---`: Always recognized when inYaml=true (fixes quarto-dev#10436) Closes quarto-dev#10436 Co-Authored-By: Claude Sonnet 4.5 <[email protected]>
Tests the fix for mid-document YAML blocks that are incorrectly parsed when the closing delimiter is followed by a blank line. Three test cases: 1. Mid-document YAML with blank line - verifies the bug fix 2. Multiple mid-document YAML blocks - tests edge cases 3. Slide separators not treated as YAML - regression test for quarto-dev#8998 The tests verify that quartoMdToJupyter() correctly creates raw cells for mid-document YAML blocks without spurious blank lines after the opening delimiter. Co-Authored-By: Claude Sonnet 4.5 <[email protected]>
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.
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 [email protected]