Skip to content

Commit f8b1e7c

Browse files
committed
fix: #28 hilightjs fenced block
1 parent d29dadb commit f8b1e7c

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

src/markdown-it-highlight.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -101,11 +101,12 @@ const highlightPlugin = md => {
101101
const token = tokens[idx]
102102
const code = token.content.trim()
103103
const lang = token.info
104+
const langObj = hljs.getLanguage(lang)
104105
let cnt
105-
if (lang) {
106-
cnt = hljs.highlightAuto(code).value
107-
} else {
106+
if (langObj) {
108107
cnt = hljs.highlight(lang, code).value
108+
} else {
109+
cnt = hljs.highlightAuto(code).value
109110
}
110111
return `<pre><code class="hljs">${cnt}</code></pre>`
111112
}

0 commit comments

Comments
 (0)