fix: missing alt attribute on images even if provided (#679) (#685)

close #679

Co-authored-by: Divyansh Singh <40380293+brc-dd@users.noreply.github.com>
pull/688/head
Brad Veryard 3 years ago committed by GitHub
parent 0d9dfe0d94
commit 3a07048533
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -10,6 +10,15 @@ export const imagePlugin = (md: MarkdownIt) => {
if (url && !EXTERNAL_URL_RE.test(url) && !/^\.?\//.test(url)) {
token.attrSet('src', './' + url)
}
if (token.attrIndex('alt') && token.children != null) {
token.attrs![token.attrIndex('alt')][1] = self.renderInlineAsText(
token.children,
options,
env
)
}
return self.renderToken(tokens, idx, options)
}
}

Loading…
Cancel
Save