Skip to content

refactor(markdown): emit continuation indent as structural CST node#9737

Merged
ematipico merged 2 commits intobiomejs:mainfrom
jfmcdowell:fix-md-continuation-indent-grammar
Mar 31, 2026
Merged

refactor(markdown): emit continuation indent as structural CST node#9737
ematipico merged 2 commits intobiomejs:mainfrom
jfmcdowell:fix-md-continuation-indent-grammar

Conversation

@jfmcdowell
Copy link
Copy Markdown
Contributor

@jfmcdowell jfmcdowell commented Mar 30, 2026

Note

This PR was created with AI assistance (Claude Code).

Summary

Refs #9725.

Promote list continuation indent from trivia to an explicit MdContinuationIndent CST node. This gives the formatter structural access to continuation indentation instead of relying on trivia.

  • Add MdContinuationIndent to grammar as an AnyMdLeafBlock
  • Replace skip_line_indent with emit_line_indent wrapped in MdContinuationIndent for list continuation
  • Skip MdContinuationIndent in HTML rendering and block iteration
  • Fix render_fenced_code_block indent computation now that continuation indent is structural

Test Plan

  • just test-crate biome_markdown_parser — all passed
  • just test-crate biome_markdown_formatter — all passed
  • just test-markdown-conformance — 652/652
  • just f
  • just l

Docs

N/A.

@changeset-bot
Copy link
Copy Markdown

changeset-bot bot commented Mar 30, 2026

⚠️ No Changeset found

Latest commit: 4745ed0

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@github-actions github-actions bot added A-Parser Area: parser A-Formatter Area: formatter A-Tooling Area: internal tools L-Markdown Language: Markdown labels Mar 30, 2026
@codspeed-hq
Copy link
Copy Markdown

codspeed-hq bot commented Mar 30, 2026

Merging this PR will not alter performance

✅ 28 untouched benchmarks
⏩ 228 skipped benchmarks1


Comparing jfmcdowell:fix-md-continuation-indent-grammar (a75e2ca) with main (d94b8ac)

Open in CodSpeed

Footnotes

  1. 228 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports.

@jfmcdowell jfmcdowell force-pushed the fix-md-continuation-indent-grammar branch 6 times, most recently from 467b771 to 973ae6c Compare March 30, 2026 21:34
@jfmcdowell jfmcdowell marked this pull request as ready for review March 30, 2026 21:54
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Mar 30, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: a870c59c-63d4-496d-846f-bf05f364cd67

📥 Commits

Reviewing files that changed from the base of the PR and between 4745ed0 and a75e2ca.

📒 Files selected for processing (2)
  • crates/biome_markdown_parser/src/syntax/list.rs
  • xtask/codegen/markdown.ungram
✅ Files skipped from review due to trivial changes (1)
  • crates/biome_markdown_parser/src/syntax/list.rs
🚧 Files skipped from review as they are similar to previous changes (1)
  • xtask/codegen/markdown.ungram

Walkthrough

The PR makes continuation-line indentation an explicit CST leaf by adding MdContinuationIndent across grammar, codegen, parser, formatter and HTML renderer. The parser now emits MD_CONTINUATION_INDENT instead of skipping the structural indent; codegen and kind registry include the new node; formatter rule and AsFormat/IntoFormat impls are added; AnyMdLeafBlock and HTML rendering are updated so continuation indents are treated as opaque/no-output leaf blocks. (≈70 words)

Possibly related PRs

Suggested reviewers

  • ematipico
🚥 Pre-merge checks | ✅ 2
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely summarises the main change: promoting continuation indent from trivia to a structural CST node in the markdown parser/formatter.
Description check ✅ Passed The description directly addresses the changeset, explaining the rationale, detailing specific changes across multiple files, and providing comprehensive test results.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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/list.rs`:
- Around line 2039-2043: Add regression fixtures that reproduce and lock the CST
change where an explicit MdContinuationIndent node is emitted: create a parser
snapshot test for the `#9725` reproducer that ensures the CST contains
MD_CONTINUATION_INDENT produced by the code path using p.start(),
p.emit_line_indent(state.required_indent), and ci_m.complete(p,
MD_CONTINUATION_INDENT); additionally add a formatter snapshot for the same
input to ensure to_html stays no-output but the CST shape is preserved; include
both parser and formatter test files (valid case reproducer plus any minimal
error case if applicable) so the fix is covered by the test suite.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: f1af8a13-0148-4b28-b2d9-036f9e7b3162

📥 Commits

Reviewing files that changed from the base of the PR and between 4a38b83 and 973ae6c.

⛔ Files ignored due to path filters (10)
  • crates/biome_markdown_factory/src/generated/node_factory.rs is excluded by !**/generated/**, !**/generated/** and included by **
  • crates/biome_markdown_factory/src/generated/syntax_factory.rs is excluded by !**/generated/**, !**/generated/** and included by **
  • crates/biome_markdown_parser/tests/md_test_suite/ok/fenced_code_in_list.md.snap is excluded by !**/*.snap and included by **
  • crates/biome_markdown_parser/tests/md_test_suite/ok/list_continuation_edge_cases.md.snap is excluded by !**/*.snap and included by **
  • crates/biome_markdown_parser/tests/md_test_suite/ok/list_indentation.md.snap is excluded by !**/*.snap and included by **
  • crates/biome_markdown_parser/tests/md_test_suite/ok/setext_heading_edge_cases.md.snap is excluded by !**/*.snap and included by **
  • crates/biome_markdown_syntax/src/generated/kind.rs is excluded by !**/generated/**, !**/generated/** and included by **
  • crates/biome_markdown_syntax/src/generated/macros.rs is excluded by !**/generated/**, !**/generated/** and included by **
  • crates/biome_markdown_syntax/src/generated/nodes.rs is excluded by !**/generated/**, !**/generated/** and included by **
  • crates/biome_markdown_syntax/src/generated/nodes_mut.rs is excluded by !**/generated/**, !**/generated/** and included by **
📒 Files selected for processing (9)
  • crates/biome_markdown_formatter/src/generated.rs
  • crates/biome_markdown_formatter/src/markdown/any/leaf_block.rs
  • crates/biome_markdown_formatter/src/markdown/auxiliary/continuation_indent.rs
  • crates/biome_markdown_formatter/src/markdown/auxiliary/mod.rs
  • crates/biome_markdown_parser/src/syntax/list.rs
  • crates/biome_markdown_parser/src/to_html.rs
  • crates/biome_markdown_parser/tests/spec_test.rs
  • xtask/codegen/markdown.ungram
  • xtask/codegen/src/markdown_kinds_src.rs
💤 Files with no reviewable changes (1)
  • crates/biome_markdown_parser/tests/spec_test.rs

Comment thread crates/biome_markdown_parser/src/syntax/list.rs Outdated
@jfmcdowell jfmcdowell marked this pull request as draft March 30, 2026 23:28
@jfmcdowell jfmcdowell force-pushed the fix-md-continuation-indent-grammar branch from 973ae6c to 006be48 Compare March 31, 2026 01:09
@jfmcdowell jfmcdowell marked this pull request as ready for review March 31, 2026 01:29
Add MdContinuationIndent to the grammar so list continuation indent
is represented as an explicit block-level node instead of skipped
trivia on the next token.

- Extend AnyMdLeafBlock with MdContinuationIndent in markdown.ungram
- Add MD_CONTINUATION_INDENT to kind.rs
- Replace skip_line_indent with emit_line_indent wrapped in
  MdContinuationIndent in check_continuation_indent
- Skip MdContinuationIndent in HTML rendering and block iteration
- Regenerate grammar and formatter code
@jfmcdowell jfmcdowell force-pushed the fix-md-continuation-indent-grammar branch from 006be48 to 4745ed0 Compare March 31, 2026 13:33
Copy link
Copy Markdown
Contributor

@dyc3 dyc3 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's a bit hard for me to understand what a "Continuation Indent" is.

@jfmcdowell
Copy link
Copy Markdown
Contributor Author

It's a bit hard for me to understand what a "Continuation Indent" is.

@dyc3 it is the whitespace that keeps continuation lines inside a list item (CommonMark §5.2). Example: the two spaces before bar in:

- foo
  bar

I added a clarifying comment.

@dyc3
Copy link
Copy Markdown
Contributor

dyc3 commented Mar 31, 2026

oh, i see, makes sense then

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-Formatter Area: formatter A-Parser Area: parser A-Tooling Area: internal tools L-Markdown Language: Markdown

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants