Skip to content

[lexical-markdown] Fix: Prevent markdown shortcut link transformer from being too greedy#8161

Merged
etrepum merged 1 commit intofacebook:mainfrom
etrepum:markdown-link-wrapping
Feb 22, 2026
Merged

[lexical-markdown] Fix: Prevent markdown shortcut link transformer from being too greedy#8161
etrepum merged 1 commit intofacebook:mainfrom
etrepum:markdown-link-wrapping

Conversation

@etrepum
Copy link
Copy Markdown
Collaborator

@etrepum etrepum commented Feb 21, 2026

Description

The RegExp used for the link markdown transformer was too greedy and could match a preceding link with unbalanced brackets if two are processed on the same line.

Closes #8129
Closes #8130

Test plan

New unit tests to confirm that import works as expected and that it now works correctly with shortcuts

@vercel
Copy link
Copy Markdown

vercel bot commented Feb 21, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
lexical Ready Ready Preview, Comment Feb 21, 2026 10:03pm
lexical-playground Ready Ready Preview, Comment Feb 21, 2026 10:03pm

Request Review

@meta-cla meta-cla bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Feb 21, 2026
@etrepum etrepum added the extended-tests Run extended e2e tests on a PR label Feb 21, 2026
/(?:\[(.+?)\])(?:\((?:([^()\s]+)(?:\s"((?:[^"]*\\")*[^"]*)"\s*)?)\))/,
regExp:
/(?:\[(.+?)\])(?:\((?:([^()\s]+)(?:\s"((?:[^"]*\\")*[^"]*)"\s*)?)\))$/,
/(?:\[([^[\]]*(?:\[[^[\]]*\][^[\]]*)*)\])(?:\((?:([^()\s]+)(?:\s"((?:[^"]*\\")*[^"]*)"\s*)?)\))$/,
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

I did let claude update this based on the tests I wrote, I did not thoroughly audit it to make sure that it passes the entire commonmark spec, but it does a better job than what was there before.

@etrepum etrepum added this pull request to the merge queue Feb 22, 2026
Merged via the queue into facebook:main with commit 7e47270 Feb 22, 2026
46 checks passed
@etrepum etrepum mentioned this pull request Feb 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. extended-tests Run extended e2e tests on a PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bug: markdown link transformer wraps the entire line into a link

3 participants