Sun, 19 Jul 2020 11:12:54 -0500
Replace local links to .md by corresponding .html on build (markdown-it only).
markdown_it.js | file | annotate | diff | comparison | revisions | |
package.json | file | annotate | diff | comparison | revisions |
--- a/markdown_it.js Fri Jul 17 12:25:24 2020 -0500 +++ b/markdown_it.js Sun Jul 19 11:12:54 2020 -0500 @@ -38,6 +38,8 @@ } try{ + // Replace local links to .md by .html. + var md_to_html=/^((?![a-zA-Z0-9]*:\/\/).*)\.md$/; var md = require('markdown-it')({ html: true, xhtmlOut: true, @@ -50,11 +52,15 @@ } catch (__){} } return ''; + }, + replaceLink: function (link, env) { + return link.replace(md_to_html, "$1.html") } }) var mk = require('@neilsustc/markdown-it-katex'); var mm = require('markdown-it-mark'); - md.use(mk, katexOptions).use(mm); + var mr = require('markdown-it-replace-link'); + md.use(mk, katexOptions).use(mm).use(mr); output = md.render(input); } catch(e) { console.error(e.stack || e.message || String(e));
--- a/package.json Fri Jul 17 12:25:24 2020 -0500 +++ b/package.json Sun Jul 19 11:12:54 2020 -0500 @@ -14,7 +14,8 @@ "@neilsustc/markdown-it-katex": "^0.5.0", "highlight.js": "^10.1.1", "markdown-it": "^11.0.0", - "markdown-it-mark": "^3.0.0" + "markdown-it-mark": "^3.0.0", + "markdown-it-replace-link": "^1.1.0" }, "devDependencies": {}, "scripts": {