Make Markdown urls open in _blank

This commit is contained in:
Chen-I Lim 2020-10-21 16:06:11 -07:00
parent 3dfeeeba6d
commit 3f35d615c0

View file

@ -47,7 +47,9 @@ class Utils {
static htmlFromMarkdown(text: string): string {
// HACKHACK: Somehow, marked doesn't encode angle brackets
const html = marked(text.replace(/</g, '&lt;'))
const renderer = new marked.Renderer()
renderer.link = ( href, title, text ) => `<a target="_blank" href="${ href }" title="${ title || '' }">${ text }</a>`
const html = marked(text.replace(/</g, '&lt;'), { renderer })
return html
}