Sun, 19 Jul 2020 11:17:28 -0500
improve regex
markdown_it.js | file | annotate | diff | comparison | revisions |
--- a/markdown_it.js Sun Jul 19 11:12:54 2020 -0500 +++ b/markdown_it.js Sun Jul 19 11:17:28 2020 -0500 @@ -39,7 +39,8 @@ try{ // Replace local links to .md by .html. - var md_to_html=/^((?![a-zA-Z0-9]*:\/\/).*)\.md$/; + var re_nonlocal=/^[a-zA-Z0-9]*:\/\//; + var re_md_to_html=/^(.*)\.md$/; var md = require('markdown-it')({ html: true, xhtmlOut: true, @@ -54,7 +55,11 @@ return ''; }, replaceLink: function (link, env) { - return link.replace(md_to_html, "$1.html") + if(link.match(re_nonlocal)){ + return link; + }else{ + return link.replace(re_md_to_html, "$1.html"); + } } }) var mk = require('@neilsustc/markdown-it-katex');