|
|
@ -7,9 +7,10 @@ export const imagePlugin = (md: MarkdownIt) => {
|
|
|
|
const imageRule = md.renderer.rules.image!
|
|
|
|
const imageRule = md.renderer.rules.image!
|
|
|
|
md.renderer.rules.image = (tokens, idx, options, env, self) => {
|
|
|
|
md.renderer.rules.image = (tokens, idx, options, env, self) => {
|
|
|
|
const token = tokens[idx]
|
|
|
|
const token = tokens[idx]
|
|
|
|
const url = token.attrGet('src')
|
|
|
|
let url = token.attrGet('src')
|
|
|
|
if (url && !EXTERNAL_URL_RE.test(url) && !/^\.?\//.test(url)) {
|
|
|
|
if (url && !EXTERNAL_URL_RE.test(url)) {
|
|
|
|
token.attrSet('src', './' + url)
|
|
|
|
if (!/^\.?\//.test(url)) url = './' + url
|
|
|
|
|
|
|
|
token.attrSet('src', decodeURIComponent(url))
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return imageRule(tokens, idx, options, env, self)
|
|
|
|
return imageRule(tokens, idx, options, env, self)
|
|
|
|
}
|
|
|
|
}
|
|
|
|