Skip to content

Commit

Permalink
fix: decode image src so that rollup can process it (#933)
Browse files Browse the repository at this point in the history
  • Loading branch information
brc-dd committed Jul 8, 2022
1 parent 1e9a7ac commit bb41a9f
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/node/markdown/plugins/image.ts
Expand Up @@ -7,9 +7,10 @@ export const imagePlugin = (md: MarkdownIt) => {
const imageRule = md.renderer.rules.image!
md.renderer.rules.image = (tokens, idx, options, env, self) => {
const token = tokens[idx]
const url = token.attrGet('src')
if (url && !EXTERNAL_URL_RE.test(url) && !/^\.?\//.test(url)) {
token.attrSet('src', './' + url)
let url = token.attrGet('src')
if (url && !EXTERNAL_URL_RE.test(url)) {
if (!/^\.?\//.test(url)) url = './' + url
token.attrSet('src', decodeURIComponent(url))
}
return imageRule(tokens, idx, options, env, self)
}
Expand Down

0 comments on commit bb41a9f

Please sign in to comment.