Skip to content

fix: an unmatched strong run before emphasis stays literal#4008

Open
spokodev wants to merge 1 commit into
markedjs:masterfrom
spokodev:w33/marked-unclosed-strong-orphan
Open

fix: an unmatched strong run before emphasis stays literal#4008
spokodev wants to merge 1 commit into
markedjs:masterfrom
spokodev:w33/marked-unclosed-strong-orphan

Conversation

@spokodev

@spokodev spokodev commented Jul 2, 2026

Copy link
Copy Markdown

The input **a*b*c produced malformed output.

  • marked: <p>*<em>a</em>b*c</p>
  • CommonMark 0.31.2 reference and markdown-it: <p>**a<em>b</em>c</p>

When the ** opener finds no closer, the lexer reprocesses from the second *
of the run. That mid-run * greedily pairs with the * before b, even though
that * is itself the opener of *b*. The unmatched ** should stay literal
while the inner *b* forms its own emphasis.

The fix marks an opener that is reprocessed from inside its own delimiter run
(prevChar equals the delimiter character) and stops it from closing against an
ambiguous delimiter that can also open, so that delimiter opens its own span
instead. This is distinct from the valid cases **foo*, ***foo** and
****foo*, which close against unambiguous right delimiters and are preserved.

All CommonMark and marked spec tests pass. Added a spec fixture for the case.

@vercel

vercel Bot commented Jul 2, 2026

Copy link
Copy Markdown

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

A member of the Team first needs to authorize it.

@UziTech UziTech left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks! 💯

@vercel

vercel Bot commented Jul 2, 2026

Copy link
Copy Markdown

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

Project Deployment Actions Updated (UTC)
marked-website Ready Ready Preview, Comment Jul 2, 2026 3:46pm

Request Review

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.

2 participants