Skip to content

fix: resolve reference links whose definition is in another block - #666

Merged
farnabaz merged 1 commit into
vercel:mainfrom
DevVettel:fix/cross-block-link-references
Oct 12, 2026
Merged

farnabaz merged 1 commit into
vercel:mainfrom
DevVettel:fix/cross-block-link-references

Conversation

@DevVettel

Copy link
Copy Markdown
Contributor

Fixes #665 (reference link part).

Cause: each block is parsed into its own mdast tree, so a [1]: url definition in another block is invisible to [text][1], which renders as raw text.

Fix: keep documents with link reference definitions in a single block, the same way documents with footnotes already are. Definitions are detected via the marked lexer (lexer.tokens.links), so nested ones (blockquotes, list items) are found and definition-like lines inside code are ignored. The incremental path falls back to a full parse when the tail adds a definition.

Tests: __tests__/link-references.test.tsx covers rendering, collapsed/shortcut references, nested definitions, code-block false positives, and streaming equivalence with a full parse. 4 of the 6 fail without the fix; full suite passes.

Not changed: the loose list part of the issue. Unwrapping the single <p> in loose list items is intentional since #476 (list-item-paragraphs.test.tsx), so I left that behaviour as is.

🤖 Generated with Claude Code

@vercel

vercel Bot commented Oct 11, 2026

Copy link
Copy Markdown
Contributor

@DevVettel is attempting to deploy a commit to the Vercel Team on Vercel.

A member of the Team first needs to authorize it.

@github-actions

github-actions Bot commented Oct 11, 2026 •

Copy link
Copy Markdown
Contributor

✅ All commits are signed

All 1 commit(s) in this pull request have a verified signature. Thanks!

Checked at 9265f92.

Each block is parsed into its own mdast tree, so `[text][1]` stayed as raw
text when `[1]: url` was in a different block. Keep documents with link
reference definitions in one block, as is already done for footnotes.

Definitions are detected with the marked lexer, so nested definitions
(blockquotes, list items) are found and lines inside code are ignored. The
incremental path falls back to a full parse when the tail adds one.

Fixes vercel#665

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@DevVettel
DevVettel force-pushed the fix/cross-block-link-references branch from 7a7f980 to 9265f92 Compare October 11, 2026 09:27

@farnabaz farnabaz left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

LGTM, Thanks

@farnabaz
farnabaz merged commit 2206c22 into vercel:main Oct 12, 2026
7 of 8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Reference links with a definition in another block are not resolved, and loose lists render as tight

2 participants