mirror of
https://github.com/danbulant/Nertivia-Client
synced 2026-07-05 11:00:50 +00:00
finished highlighting logic
This commit is contained in:
parent
4310341178
commit
6c5078ec3f
1 changed files with 12 additions and 1 deletions
|
|
@ -84,7 +84,18 @@ futoji.addTransformer({
|
||||||
name: 'code-block',
|
name: 'code-block',
|
||||||
symbol: '```',
|
symbol: '```',
|
||||||
recursive: false,
|
recursive: false,
|
||||||
transformer: text => `<div class="codeblock"><code>${hljs.highlightAuto(formatCode(unescapeHTML(text)).code).value}</code></div>`
|
transformer: text => {
|
||||||
|
let formatted = formatCode(unescapeHTML(text))
|
||||||
|
|
||||||
|
let highlighted
|
||||||
|
if(formatted.lang in hljs.listLanguages()) {
|
||||||
|
highlighted = hljs.highlight(formatted.lang, formatted.code, true)
|
||||||
|
} else {
|
||||||
|
highlighted = hljs.highlightAuto(formatted.code)
|
||||||
|
}
|
||||||
|
|
||||||
|
return `<div class="codeblock"><code lang="${highlighted.language}">${highlighted.value}</code></div>`
|
||||||
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
futoji.addTransformer({
|
futoji.addTransformer({
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue