marked
marked copied to clipboard
link inside of Strong delimiter, the strong delimiter not work
Marked version: https://github.com/markedjs/marked/blob/009427f65dadd5dff9ec0189e008677aea9fbcfa/lib/marked.js
Describe the bug
When there is a link inside of a strong delimiter, followed closely by a character other than [ .!,;] ...., the strong delimiter is broken.
To Reproduce

**STRONG**. OK
**STRONG**。 OK
**STRONG**! OK
**STRONG**M OK
**[STRONG]( http://abc.com )**! OK
**[STRONG]( http://abc.com )**. OK
**[STRONG]( http://abc.com )**! bad!
**[STRONG]( http://abc.com )** ! OK
**[STRONG]( http://abc.com )**M bad!
**[STRONG]( http://abc.com )** M OK
Info Old Version don't have this issue.
- A chrome extension called Markdown Preview Plus uses a relatively new version of marked, and it has this same problem.
- The browserify-markdown-editor uses an old version of marked ( 0.2.9 ), and it don't have this problem. https://thlorenz.com/browserify-markdown-editor/
Expected behavior
The strong delimiter should bolden the wrapped text no matter of what's inside and what's behind.
marked demo CommonMark demo Github Demo:
STRONG. OK
STRONG。 OK
STRONG! OK
STRONGM OK
STRONG! OK
STRONG. OK
STRONG! bad!
STRONG ! OK
**STRONG**M bad!
STRONG M OK
Looks like the second **[STRONG]( http://abc.com )**! needs to get fixed but the **[STRONG]( http://abc.com )**M is the same in CommonMark (and GitHub) so that is how it is supposed to be displayed.
PRs are always welcome 😁👍
I think the conflicting rule is this:
A right-flanking delimiter run is a delimiter run that is (1) not preceded by Unicode whitespace, and either (2a) not preceded by a punctuation character, or (2b) preceded by a punctuation character and followed by Unicode whitespace or a punctuation character. For purposes of this definition, the beginning and the end of the line count as Unicode whitespace.
In this case, the ending ** in example 3 ends with a ), and so Marked.js expects either a whitespace or a punctuation character after. Normal exclamation points (example 1) are included in our list of "punctuation characters", but the character U+FF01 : FULLWIDTH EXCLAMATION MARK in example 3 is not currently included in that list: From the Spec:
A punctuation character is an ASCII punctuation character or anything in the general Unicode categories Pc, Pd, Pe, Pf, Pi, Po, or Ps.
An ASCII punctuation character is !, ", #, $, %, &, ', (, ), *, +, ,, -, ., / (U+0021–2F), :, ;, <, =, >, ?, @ (U+003A–0040), [, , ], ^, _, ` (U+005B–0060), {, |, }, or ~ (U+007B–007E).
So following that, the solution is to make sure we include the general Unicode categories listed above because U+FF01 is part of the "Po (other punctuation)" set. https://www.compart.com/en/unicode/U+FF01. M however is not punctuation or whitespace, so )**M Is not valid.