Skip to content

fix(markdown_parser): reject link reference definition with trailing text after destination#9780

Merged
ematipico merged 1 commit intobiomejs:mainfrom
jfmcdowell:fix/md-link-def-trailing-text
Apr 6, 2026
Merged

fix(markdown_parser): reject link reference definition with trailing text after destination#9780
ematipico merged 1 commit intobiomejs:mainfrom
jfmcdowell:fix/md-link-def-trailing-text

Conversation

@jfmcdowell
Copy link
Copy Markdown
Contributor

Note

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

Summary

The bare-destination loop in skip_destination_tokens continued past whitespace into non-title text, treating [label]: /url invalid as a valid link reference definition with destination /url invalid. Now the loop stops at the first whitespace boundary when followed by non-title content, correctly rejecting the line as a definition per CommonMark §4.7.

Test Plan

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

Docs

N/A.

…text after destination

Stop the bare-destination loop in skip_destination_tokens at the first
whitespace boundary when followed by non-title text. Previously the
loop absorbed spaces and continued, treating `[label]: /url invalid`
as a valid definition with destination `/url invalid`.
@changeset-bot
Copy link
Copy Markdown

changeset-bot bot commented Apr 2, 2026

⚠️ No Changeset found

Latest commit: a804b2c

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 Apr 2, 2026
@codspeed-hq
Copy link
Copy Markdown

codspeed-hq bot commented Apr 2, 2026

Merging this PR will not alter performance

✅ 28 untouched benchmarks
⏩ 228 skipped benchmarks1


Comparing jfmcdowell:fix/md-link-def-trailing-text (a804b2c) with main (35305c9)

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 marked this pull request as ready for review April 2, 2026 20:09
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Apr 2, 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: b7bc512d-9e08-420f-a640-dc15bb9afc09

📥 Commits

Reviewing files that changed from the base of the PR and between 35305c9 and a804b2c.

⛔ Files ignored due to path filters (1)
  • crates/biome_markdown_parser/tests/md_test_suite/ok/link_definition_edge_cases.md.snap is excluded by !**/*.snap and included by **
📒 Files selected for processing (1)
  • crates/biome_markdown_parser/src/syntax/link_block.rs

Walkthrough

The markdown parser's skip_destination_tokens function has been modified to simplify the lookahead termination logic for bare link destinations. Previously, the parser required three conditions to end destination parsing: detecting a potential title starter, having accumulated destination content, and observing a whitespace separator. The updated logic removes the title starter check, now terminating solely on the presence of destination content followed by a whitespace boundary, thereby treating any non-title text beyond that boundary as the end of the destination.

Suggested reviewers

  • dyc3
  • ematipico
🚥 Pre-merge checks | ✅ 2
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately describes the main fix: rejecting link reference definitions with trailing text after destination, which directly matches the changeset's core objective.
Description check ✅ Passed The description is clearly related to the changeset, explaining the bug fix, its CommonMark §4.7 compliance, and test results, all consistent with the changes made.

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

@ematipico ematipico merged commit e0e4aac into biomejs:main Apr 6, 2026
15 checks passed
@jfmcdowell jfmcdowell deleted the fix/md-link-def-trailing-text branch April 13, 2026 12:29
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.

2 participants