Closed
Description
Content in my markdown file:
Run vuepress dev
, it throws an error:
Run vuepress build
, it doesn't throw an error. But the page is not rendered as expected:
I guess the cause is that code
isn't escaped, when lang is 'text' or not specified.
vuepress/lib/markdown/highlight.js
Lines 8 to 10 in 86d4055
Since prism would automatically escape code
:
> prism.highlight('<scheme>', prism.languages['html'], 'html')
'<span class="token tag"><span class="token tag"><span class="token punctuation"><</span>scheme</span><span class="token punctuation">></span></span>'
A quick solution might be:
const escapeHtml = require('escape-html')
function wrap (code, lang) {
if (lang === 'text') {
code = escapeHtml(code)
}
return `<pre v-pre class="language-${lang}"><code>${code}</code></pre>`
}
This solution works well both on vuepress dev
and vuepress build
. But I don't know if this is a good solution
Metadata
Metadata
Assignees
Labels
No labels