javascript - How to parse ordered list of wikitext to HTML using wiky.js? -
i need parse ordered list of wikitext html using wiky.js. javascript using regex that.
e.g.
# item1 # item2 # item3 # item4 ## sub-item 1 ### sub-sub-item
is displayed
1.item1 2.item2 3.item3 4.item4 1.sub-item 1 1. sub-sub-item
i need html version of code. wiky.js uses old version of parsing ordered list not supported wiki editor now.
add 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 executed in order. cover potentially infinite recursion level of <ol><li></li></ol>
tags.
i don't explain code 'cause i've used dirty expedients logic it's hard unfold.
Comments
Post a Comment