Skip to content

fix(markdown-parser): incorrect inline link R_PAREN token range#9642

Merged
dyc3 merged 2 commits into
biomejs:mainfrom
jfmcdowell:fix/inline-link-r-paren-whitespace
Mar 28, 2026
Merged

fix(markdown-parser): incorrect inline link R_PAREN token range#9642
dyc3 merged 2 commits into
biomejs:mainfrom
jfmcdowell:fix/inline-link-r-paren-whitespace

Conversation

@jfmcdowell

@jfmcdowell jfmcdowell commented Mar 28, 2026

Copy link
Copy Markdown
Contributor

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 the R_PAREN token, producing R_PAREN@65..68 " )" instead of R_PAREN@67..68 ")".

  • Root cause: skip_link_def_separator_tokens advanced the lexer without emitting tree-builder events, leaving orphaned bytes that got folded into the next token's range.
  • Fix: consume post-title separator whitespace into the title's MdInlineItemList via bump_link_def_separator (which emits proper parser events), matching the existing pattern for destination-to-title whitespace.
  • Removed the now-dead skip_link_def_separator_tokens helper.
  • Only the post-title path is changed; the no-title case ([link](/url )) was already correct.

Test Plan

  • cargo test -p biome_markdown_parser
  • just test-markdown-conformance
  • Snapshot updated: inline_link_whitespace.md.snap shows clean R_PAREN@67..68 ")" with trailing whitespace as MD_TEXTUAL@65..67 inside the title content list
  • No-title, multiline title, and link definition cases unchanged
  • just f

Docs

N/A — parser bug fix with no user-facing API change.

…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.
@changeset-bot

changeset-bot Bot commented Mar 28, 2026

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: 15582d2

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 L-Markdown Language: Markdown labels Mar 28, 2026
@jfmcdowell jfmcdowell marked this pull request as ready for review March 28, 2026 20:07
@coderabbitai

coderabbitai Bot commented Mar 28, 2026

Copy link
Copy Markdown
Contributor

Walkthrough

This 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 skip_link_def_separator_tokens is removed, consolidating separator handling into the parse_title_content flow via bump_link_def_separator calls.

Possibly related PRs

Suggested reviewers

  • ematipico
🚥 Pre-merge checks | ✅ 4
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed Title accurately summarises the main fix: correcting R_PAREN token range in inline link parsing by removing whitespace absorption.
Linked Issues check ✅ Passed Changes directly address issue #9640: post-title whitespace is now properly consumed into the title's MdInlineItemList, fixing the incorrect R_PAREN token range.
Out of Scope Changes check ✅ Passed All changes are scoped to fixing inline link R_PAREN handling; the removal of skip_link_def_separator_tokens and whitespace consumption refactoring directly support the stated objective.
Description check ✅ Passed The PR description clearly relates to the changeset, detailing a fix for inline link whitespace handling in the markdown parser with root cause, solution, and testing information.

✏️ 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.

@dyc3 dyc3 merged commit cc6f2f6 into biomejs:main Mar 28, 2026
14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-Parser Area: parser L-Markdown Language: Markdown

Projects

None yet

Development

Successfully merging this pull request may close these issues.

🐛 Incorrect inline link parsing

2 participants