-
Notifications
You must be signed in to change notification settings - Fork 3.4k
I find a code block in the list can not contain more than one blank lines. #849
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
Comments
test code: <!doctype html>
<title>marked tests</title>
<p>testing...</p>
<script src="marked.js"></script>
<script>
var str = "- test\n```\ncode\n\n```";
console.log(marked(str));
</script> ouput:
|
In the 284 line code be truncated by '\n',but the regular is too difficult.
|
你为什么要把代码区块写成```\nvar renderer = new Renderer\n``` |
@Jiang-Xuan 测试的时候字符串里没法打回车。 多行代码: 我遇到的是列表下面的多行代码有回车会被截断: ``` 这种情况- lsit2被标记成了代码,我是想让testcode1,testcode2成为代码 |
@1010543618 |
@1010543618 |
@Jiang-Xuan 我是这几天才看的markdown,以前一直没接触过,感觉每种解析器的解析都有点差别。我是准备想办法让```包裹的代码块里的换行不被列表的-识别了当成结束列表,但js没学好=_=。我再试试不然就像你说的先结束了列表在用代码块。十分感谢^_^ |
@1010543618 解析器都有自己的语法,想要自己有一种语法,只能去重写全部源代码或者一部分,我就在重写这个包来让它更符合我的博客站点,所以才看到你的问题=_=。同样是菜鸟 |
@Jiang-Xuan 恩,造个轮子可有点难。反正假期有空好好研究研究作者的代码 |
use
|
@fadiquader |
Uh oh!
There was an error while loading. Please reload this page.
I find a code block in the list can not contain more than one blank lines.
(list下面的代码块有两个以上换行会解析错误)
Solution(解决方法)
Let the list matching to the end of the [\s\S]?```,and plus the
(?![\s\S]*?```)
in the regular expression.(让列表匹配到[\s\S]?```结束,正则表达式中加上
(?![\s\S]*?```)
)Change marked.js->line22 To
list: /^( *)(bull) [\s\S]+?(?:hr|def|\n{2,}(?! )(?!\1bull )(?![\s\S]*?```)\n*|\s*$)/,
(将marked.js的22行换成:
list: /^( *)(bull) [\s\S]+?(?:hr|def|\n{2,}(?! )(?!\1bull )(?![\s\S]*?```)\n*|\s*$)/,)
like this(please remove '\')(例如这样会解析错):
I checked block.gfm and block.list but it beyond my ability to found the wrong.
PS: I am a Chinese boy is not good at English and javascript.Please don't keep in mind if I say something wrong.
The text was updated successfully, but these errors were encountered: