Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

link inside of Strong delimiter, the strong delimiter not work #2041

Closed
KnIfER opened this issue May 7, 2021 · 3 comments · Fixed by #2811
Closed

link inside of Strong delimiter, the strong delimiter not work #2041

KnIfER opened this issue May 7, 2021 · 3 comments · Fixed by #2811
Labels
category: mixed content L2 - annoying Similar to L1 - broken but there is a known workaround available for the issue

Comments

@KnIfER
Copy link

KnIfER commented May 7, 2021

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
image

**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.

Expected behavior
The strong delimiter should bolden the wrapped text no matter of what's inside and what's behind.

@UziTech
Copy link
Member

UziTech commented May 7, 2021

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.

@UziTech UziTech added category: mixed content L2 - annoying Similar to L1 - broken but there is a known workaround available for the issue labels May 7, 2021
@UziTech
Copy link
Member

UziTech commented May 7, 2021

PRs are always welcome 😁👍

@calculuschild
Copy link
Contributor

calculuschild commented May 7, 2021

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
category: mixed content L2 - annoying Similar to L1 - broken but there is a known workaround available for the issue
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants