Skip to content

fix: pedantic **foo:** and **"word"** emphasis parsing#3999

Open
waiter wants to merge 2 commits into
markedjs:masterfrom
waiter:fix_strong
Open

fix: pedantic **foo:** and **"word"** emphasis parsing#3999
waiter wants to merge 2 commits into
markedjs:masterfrom
waiter:fix_strong

Conversation

@waiter

@waiter waiter commented Jun 22, 2026

Copy link
Copy Markdown

Marked version:

18.0.5 / master

Markdown flavor: Markdown.pl / pedantic

Description

  • Fixes 3938
  • Inspired by the fix in markedjs/marked#3959, this implementation further optimizes emphasis and strong parsing for broader edge cases, such as:
**foo:**bar

**foo**bar

*foo:*bar

_foo:_bar

__foo:__bar

aa**"A"**and**"B"**aa

aa**'A'**and**'B'**aa

**'test'**  
image

Contributor

  • Test(s) exist to ensure functionality and minimize regression (if no tests added, list tests covering this PR); or,
  • no tests required for this PR.
  • If submitting new feature, it has been documented in the appropriate places.

Committer

In most cases, this should be a different person than the contributor.

@vercel

vercel Bot commented Jun 22, 2026

Copy link
Copy Markdown

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

A member of the Team first needs to authorize it.

@vercel

vercel Bot commented Jun 22, 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 21, 2026 5:52am

Request Review

@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! this is great 💯

@UziTech
UziTech requested review from calculuschild and styfle June 24, 2026 06:32
Comment thread src/rules.ts Outdated
.replace(/punctSpace/g, _punctuationOrSpace).getRegex();

/** Quote chars for pedantic rule 6 lookbehind; includes both straight and curly forms. */
const closeQuoteClass = '["\u201c\u201d\u2018\u2019\']';

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

openQuoteClass and closeQuoteClass are asymmetric (” only exists in the latter). If that's intentional, I'd add a test to pin the behavior; otherwise it looks like an easy regression candidate.

Comment thread src/rules.ts Outdated
+ '|(?!\\*)[\\s](\\*+)(?=notPunctSpace)' // (3) ***a can only be Left Delimiter (whitespace required; not #***a)
+ '|[\\s](\\*+)(?!\\*)(?=punct)' // (4) ***# can only be Left Delimiter
+ '|(?!\\*)punct(\\*+)(?!\\*)(?=punct)' // (5) #***# can be either Left or Right Delimiter
+ '|closeQuoteLookbehind(?:(?!\\*)punct|notPunctSpace)(\\*+)(?!\\*)(?=notPunctSpace)'; // (6) a***a, #***a, and :** (e.g. **foo:**bar)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

This changes pedantic parsing for some "aa-style edge cases. The new behavior may well be preferable, but since it's a silent regression, I'd add a regression test to explicitly pin the intended behavior

@waiter

waiter commented Jul 21, 2026

Copy link
Copy Markdown
Author

Updated! Expanded coverage for more strong/emphasis patterns, tuned Rule 6, and added test cases.

@UziTech @hongarc PTAL when you get a chance!

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.

3 participants