refactor(markdown-parser): promote fenced code block skipped trivia to explicit CST nodes#9321
refactor(markdown-parser): promote fenced code block skipped trivia to explicit CST nodes#9321jfmcdowell wants to merge 5 commits intobiomejs:mainfrom
Conversation
|
…o explicit CST nodes Replace 4 parse_as_skipped_trivia_tokens() call sites in fenced_code_block.rs: - Sites 1-3: blockquote > prefixes on continuation lines emit MdQuotePrefix nodes - Site 4: fence indent stripping emits MdIndentToken nodes Add MdIndentToken to AnyMdInline in the grammar and regenerate codegen. Add MdIndentToken no-op arm in to_html.rs extract_alt_text_inline. Add error fixture documenting pre-existing fenced-code-in-blockquote limitation. Extract try_bump_quote_marker as pub(crate) to deduplicate marker-bumping logic.
ccff014 to
041e82b
Compare
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review infoConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: ⛔ Files ignored due to path filters (1)
📒 Files selected for processing (3)
WalkthroughThis PR introduces Possibly related PRs
Suggested reviewers
🚥 Pre-merge checks | ✅ 2✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@crates/biome_markdown_parser/src/syntax/fenced_code_block.rs`:
- Around line 370-373: The call to try_bump_quote_marker(p) is inside
debug_assert! so it is skipped in release builds and the parser state won't be
updated; replace the debug_assert! invocation with an unconditional call to
try_bump_quote_marker(p) (so the marker is always consumed) and keep an optional
debug-only check if desired (e.g., call try_bump_quote_marker(p) and then
debug_assert!(result, "guard above guarantees marker present")); update the code
around the debug_assert! to call try_bump_quote_marker(p) unconditionally and
handle a false result only via debug assertion or by panicking with the same
message.
ℹ️ Review info
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: 02a409d7-7cbc-4b18-996b-0f5447559e8c
⛔ Files ignored due to path filters (3)
crates/biome_markdown_parser/tests/md_test_suite/error/fenced_code_in_blockquote.md.snapis excluded by!**/*.snapand included by**crates/biome_markdown_parser/tests/md_test_suite/ok/fenced_code_advanced.md.snapis excluded by!**/*.snapand included by**crates/biome_markdown_syntax/src/generated/nodes.rsis excluded by!**/generated/**,!**/generated/**and included by**
📒 Files selected for processing (6)
crates/biome_markdown_formatter/src/markdown/any/inline.rscrates/biome_markdown_parser/src/syntax/fenced_code_block.rscrates/biome_markdown_parser/src/syntax/quote.rscrates/biome_markdown_parser/src/to_html.rscrates/biome_markdown_parser/tests/md_test_suite/error/fenced_code_in_blockquote.mdxtask/codegen/markdown.ungram
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@crates/biome_markdown_parser/src/syntax/fenced_code_block.rs`:
- Around line 314-335: The code currently sets at_line_start = false immediately
after consume_quote_prefixes_in_code_content, which prevents the later
fence-indent stripping block (skip_fenced_content_indent and at_closing_fence)
from running for lines inside blockquotes; update the loop in
fenced_code_block.rs so fence-indent stripping runs after quote prefix
consumption: after calling consume_quote_prefixes_in_code_content (function
name) and before or regardless of resetting at_line_start, call
skip_fenced_content_indent when fence_indent > 0 and then re-check
at_closing_fence (function name) — or alternatively handle blockquote-nested
indentation explicitly by adding a branch that strips fence_indent even when
at_line_start was just true and quote prefixes were consumed; ensure
CodeContentLoopAction semantics and the at_line_start flag are preserved.
ℹ️ Review info
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: 7e51518c-9db4-4808-9efb-2a5a282df782
📒 Files selected for processing (1)
crates/biome_markdown_parser/src/syntax/fenced_code_block.rs
Use virtual_line_start in line_has_closing_fence so fence detection starts after consumed quote prefixes instead of seeing `>` as non-whitespace. Set virtual_line_start after quote prefix consumption and allow fence-indent stripping to run on blockquote lines.
Note
AI Assistance Disclosure: This PR was developed with assistance from Claude Code.
Summary
MdIndentTokentoAnyMdInlinein the grammar for fence indent stripping tokens.parse_as_skipped_trivia_tokens()call sites infenced_code_block.rswith explicit CST node emission:>prefixes on continuation lines within fenced code blocks now emitMdQuotePrefixnodes (withMdQuoteIndentList, marker, and optional post-marker space).MdIndentTokennodes withMD_INDENT_CHARtokens.MdIndentTokenno-op arm into_html.rsextract_alt_text_inlineexhaustive match.biome_markdown_syntax,biome_markdown_formatter).fenced_code_in_blockquote.mddocumenting pre-existing limitation where fenced code blocks inside blockquotes produce unterminated fence diagnostics.fenced_code_advanced.mdsnapshot to reflect new CST shape.Continues the skipped trivia promotion series (#9219, #9274, #9313). Sites 1-3 (quote prefixes in code content) are structurally correct but exercised only via the pre-existing blockquote+fenced-code path which has a known limitation — the error fixture documents current behavior until a follow-up fix lands.
No user-facing behavior change. Parsed semantics are preserved; only the internal CST representation changes.
Test Plan
just test-crate biome_markdown_parserjust test-markdown-conformancejust f && just lDocs
N/A — internal structural change, no new user-facing features.