markedjs / marked

A markdown parser and compiler. Built for speed.
https://marked.js.org
Other
33.07k stars 3.39k forks source link

When bold content contains special symbols, parsing error occurs #3410

Closed xiaosenmao closed 2 months ago

xiaosenmao commented 2 months ago

Marked version: 14.0.0

Describe the bug When bold content contains special symbols, parsing error occurs

To Reproduce Steps to reproduce the behavior:

If possible, use the Marked Demo permalink and compare to the CommonMark Dingus permalink to demonstrate the bug

  1. Marked Demo
  2. CommonMark Demo eg: https://marked.js.org/demo/?text=-%20**2024%E6%AC%BE%20700km%20%E5%90%8E%E9%A9%B1%E9%95%BF%E7%BB%AD%E8%88%AA%E6%99%BA%E9%A9%BE%E7%89%88**%EF%BC%9A%E5%90%8E%E7%BD%AE%E5%90%8E%E9%A9%B1%EF%BC%8C%E6%8C%87%E5%AF%BC%E4%BB%B7**%EF%BF%A521.59%E4%B8%87**%EF%BC%8C%E9%9B%B6%E7%99%BE%E5%8A%A0%E9%80%9F**5.28%E7%A7%92**%E3%80%82%0A&options=%7B%0A%20%22async%22%3A%20false%2C%0A%20%22breaks%22%3A%20false%2C%0A%20%22extensions%22%3A%20null%2C%0A%20%22gfm%22%3A%20true%2C%0A%20%22hooks%22%3A%20null%2C%0A%20%22pedantic%22%3A%20false%2C%0A%20%22silent%22%3A%20false%2C%0A%20%22tokenizer%22%3A%20null%2C%0A%20%22walkTokens%22%3A%20null%0A%7D&version=14.0.0
截屏2024-08-14 12 28 43
UziTech commented 2 months ago

It looks like marked does the same thing as commonmark

I think the issue you are seeing is because the commonmark spec has very specific conditions on what can be to the left and right of it.

xiaosenmao commented 2 months ago

Thank you, but the result seems abnormal when the bold text in the example contains the currency symbol ¥ or $.

UziTech commented 2 months ago

You can try to suggest a change to the commonmark spec since that is what marked follows to know how markdown should be converted to html. If they change the spec we can change marked to follow it.

sissifly commented 2 months ago

If some characters appear in the middle and end of ** at the same time, strong text cannot be parsed. will check commonmark spec

image