1
0
mirror of https://github.com/BoostIo/Boostnote synced 2025-12-13 09:46:22 +00:00

Markdown内のコードにSyntax highlightenをいれる

This commit is contained in:
Rokt33r
2015-11-23 10:39:21 +09:00
parent d5265407b9
commit cc2a2f6dfb
7 changed files with 23 additions and 7 deletions

View File

@@ -1,8 +1,22 @@
import markdownit from 'markdown-it'
import hljs from 'highlight.js'
var md = markdownit({
typographer: true,
linkify: true
linkify: true,
highlight: function (str, lang) {
if (lang && hljs.getLanguage(lang)) {
try {
return hljs.highlight(lang, str).value;
} catch (__) {}
}
try {
return hljs.highlightAuto(str).value;
} catch (__) {}
return ''; // use external default escaping
}
})
export default function markdown (content) {