fix(markdown-parser): incorrect inline link R_PAREN token range#9642
Conversation
…AREN token Fixes biomejs#9640. When parsing inline links with titles like `[link](/uri "title" )`, the trailing whitespace before `)` was being absorbed into the R_PAREN token range, producing `R_PAREN@65..68 " )"` instead of `R_PAREN@67..68 ")"`. Root cause: `skip_link_def_separator_tokens` advanced the lexer via `p.bump_link_definition()` without emitting tree-builder events, leaving orphaned bytes that got folded into the next recorded token. Fix: consume post-title trailing whitespace into the title's MdInlineItemList using `bump_link_def_separator` (which emits proper parser events), matching the pattern already used for destination-to-title separator whitespace.
|
WalkthroughThis change refactors inline link title parsing in the markdown parser. Rather than skipping trailing whitespace and newlines separately before consuming the closing parenthesis, the parser now includes these separators as part of the title's inline item list. The helper function Possibly related PRs
Suggested reviewers
🚥 Pre-merge checks | ✅ 4✅ Passed checks (4 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 |
Note
AI Assistance Disclosure: This PR was developed with assistance from Claude Code.
Summary
Fixes #9640.
When parsing inline links with titles (e.g.
[link](/uri "title" )), trailing whitespace before)was absorbed into theR_PARENtoken, producingR_PAREN@65..68 " )"instead ofR_PAREN@67..68 ")".skip_link_def_separator_tokensadvanced the lexer without emitting tree-builder events, leaving orphaned bytes that got folded into the next token's range.MdInlineItemListviabump_link_def_separator(which emits proper parser events), matching the existing pattern for destination-to-title whitespace.skip_link_def_separator_tokenshelper.[link](/url )) was already correct.Test Plan
cargo test -p biome_markdown_parserjust test-markdown-conformanceinline_link_whitespace.md.snapshows cleanR_PAREN@67..68 ")"with trailing whitespace asMD_TEXTUAL@65..67inside the title content listjust fDocs
N/A — parser bug fix with no user-facing API change.