How to parse ordered list of wikitext to HTML using wiky.js?

末鹿安然 提交于 2019-12-04 22:09:28

Add the following:

{
    rex: /^((#*)[^#].*(\n))(?=#\2)/gm,
    tmplt: "$1<ol>$3"
},
{
    rex: /^((#+).*(\n))(?!\2|<ol)/gm,
    tmplt: "$1</ol>$2.$2$3"
},
{
    rex: /#(?=(#+)\.#+\n(?!\1))/gm,
    tmplt: "</ol>"
},
{
    rex: /(<\/ol>)[#.]+/gm,
    tmplt: "$1"
},
{
    rex: /^((#+).*(\n))(?=\2[^#]|<\/ol)/gm,
    tmplt: "$1</li>$3"
},
{
    rex: /^(<\/ol>(\n)*)#+/gm,
    tmplt: "$1</li>$2<li>"
},
{
    rex: /^#+/gm,
    tmplt: "<li>"
}

Hoping they are executed in this order. This will cover a potentially infinite recursion level of <ol><li></li></ol> tags.

I don't explain you the code 'cause I've used some dirty expedients whose logic it's hard to unfold.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!