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

Bug with asterisks (if this is the current version of GFM on GitHub) #520

Closed
alanhogan opened this issue Dec 5, 2014 · 10 comments
Closed
Labels
category: inline elements L1 - broken Valid usage causes incorrect output OR a crash AND there is no known workaround for the issue

Comments

@alanhogan
Copy link

Sorry if this is filed incorrectly, but strings like this are not formatted correctly:

Test *italic here **bold italic here** and italic still* end

See also http://ajh.us/babelmark2-asterisks-bold-in-italic-test

@alanhogan alanhogan changed the title Bug (if this is the current version of GFM on GitHub) Bug with asterisks (if this is the current version of GFM on GitHub) Dec 5, 2014
@CoDEmanX
Copy link

CoDEmanX commented Sep 4, 2015

It also fails at a very simple:

text text *five \*six* text

Result should look like:

text text five * six text

http://johnmacfarlane.net/babelmark2/?normalize=1&text=text+text+*five+\*+six*

@sunil-ideas2it
Copy link

Anyone got fix for this .

@joshbruce
Copy link
Member

Closing as covered by spec-compliance. See also #1106 and #1216

@Feder1co5oave
Copy link
Contributor

This still fails:

text text *five \*six* text
<p>text text <em>five \</em>six* text</p>

@UziTech UziTech reopened this Dec 6, 2018
@UziTech UziTech added L1 - broken Valid usage causes incorrect output OR a crash AND there is no known workaround for the issue category: inline elements labels Dec 6, 2018
@rtxa
Copy link

rtxa commented May 5, 2019

Hi, I've fixed this by not matching the backslash character in the regex for the 5th capturing group, this needs to be tested to ensure there aren't side effects. Check this Regex demo

Original code:

em: /^_([^\s_])_(?!_)|^\*([^\s*"<\[])\*(?!\*)|^_([^\s][\s\S]*?[^\s_])_(?!_|[^\spunctuation])|^_([^\s_][\s\S]*?[^\s])_(?!_|[^\spunctuation])|^\*([^\s"<\[][\s\S]*?[^\s*])\*(?!\*)|^\*([^\s*"<\[][\s\S]*?[^\s])\*(?!\*)/,

Fix:

em: /^_([^\s_])_(?!_)|^\*([^\s*"<\[])\*(?!\*)|^_([^\s][\s\S]*?[^\s_])_(?!_|[^\spunctuation])|^_([^\s_][\s\S]*?[^\s])_(?!_|[^\spunctuation])|^\*([^\s"<\[][\s\S]*?[^\s*\\])\*(?!\*)|^\*([^\s"<\[][\s\S]*?[^\s*\\])\*(?!\*)/,

@UziTech
Copy link
Member

UziTech commented May 6, 2019

@rtxa you should create a PR so it can be tested by our test suite

@lynzrand
Copy link

lynzrand commented Nov 2, 2020

Sorry to dig up this issue, but is there any updates on this issue? Seems it's still present as of v1.2.2.

@UziTech
Copy link
Member

UziTech commented Nov 2, 2020

There are still some issues with em but it looks like the original bug is fixed:

Test *italic here **bold italic here** and italic still* end

<p>Test <em>italic here <strong>bold italic here</strong> and italic still</em> end</p>

demo

@01010101lzy if you have other markdown that is not working you can create a different issue.

@UziTech UziTech closed this as completed Nov 2, 2020
@lynzrand
Copy link

lynzrand commented Nov 3, 2020

There are still some issues with em but it looks like the original bug is fixed:

Test *italic here **bold italic here** and italic still* end

<p>Test <em>italic here <strong>bold italic here</strong> and italic still</em> end</p>

demo

@01010101lzy if you have other markdown that is not working you can create a different issue.

The problem mentioned in the first reply of this issue (asterisks are not properly escaped) is still lying around unfortunately...

https://marked.js.org/demo/?text=*test%5C*%20123*&options=%7B%20%22baseUrl%22%3A%20null%2C%20%22breaks%22%3A%20false%2C%20%22gfm%22%3A%20true%2C%20%22headerIds%22%3A%20true%2C%20%22headerPrefix%22%3A%20%22%22%2C%20%22highlight%22%3A%20null%2C%20%22langPrefix%22%3A%20%22language-%22%2C%20%22mangle%22%3A%20true%2C%20%22pedantic%22%3A%20false%2C%20%22sanitize%22%3A%20false%2C%20%22sanitizer%22%3A%20null%2C%20%22silent%22%3A%20false%2C%20%22smartLists%22%3A%20false%2C%20%22smartypants%22%3A%20false%2C%20%22tokenizer%22%3A%20null%2C%20%22walkTokens%22%3A%20null%2C%20%22xhtml%22%3A%20false%7D&version=master

@UziTech
Copy link
Member

UziTech commented Nov 3, 2020

@01010101lzy yes that is still an issue. If you want to you can create a different issue to track that bug. PRs are also welcome. 😁

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
category: inline elements L1 - broken Valid usage causes incorrect output OR a crash AND there is no known workaround for the issue
Projects
None yet
Development

No branches or pull requests

8 participants