Forced decoding image src for non-ascii chars
npm install --save-dev markdown-it-disable-url-encode const md = require("markdown-it")();
md.use(require("markdown-it-disable-url-encode"), "./")
// md.use(require("markdown-it-disable-url-encode"), "*")
// md.use(require("markdown-it-disable-url-encode"), ".")
// md.use(require("markdown-it-disable-url-encode"), [...])
// md.use(require("markdown-it-disable-url-encode"), /.../)
const html = md.render("")
// <p><img src="./图片/image.png" alt="image.png" /></p>
// without markdown-it-disable-url-encode plugin :
// <p><img src="%E5%9B%BE%E7%89%87/image.png" alt="image.png" /></p> config rules:
0. undefined : use rule 1
-
"*": all paths will be decode -
".": relative paths only -
"./": relative paths only , just like"." -
string: asstring[]to applyrule 5 -
string[]: will be apply[].some()as result for detect if it needs to be decoded -
REGEXP: will be apply/^/.test()as result for detect if it needs to be decoded