Skip to content

Commit ac4acab

Browse files
lazzzisyyx990803
authored andcommitted
fix: escape text in code block when lang is text or not specified #31 (#32)
1 parent 15a1ac8 commit ac4acab

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

lib/markdown/highlight.js

+4
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,15 @@
11
const chalk = require('chalk')
22
const prism = require('prismjs')
33
const loadLanguages = require('prismjs/components/index')
4+
const escapeHtml = require('escape-html')
45

56
// required to make embedded highlighting work...
67
loadLanguages(['markup', 'css', 'javascript'])
78

89
function wrap (code, lang) {
10+
if (lang === 'text') {
11+
code = escapeHtml(code)
12+
}
913
return `<pre v-pre class="language-${lang}"><code>${code}</code></pre>`
1014
}
1115

0 commit comments

Comments
 (0)