mirror of
https://github.com/danbulant/Nertivia-Client
synced 2026-07-04 10:30:37 +00:00
fixed an issue with leading newlines
This commit is contained in:
parent
36e19ea08f
commit
7fbadc711d
1 changed files with 4 additions and 2 deletions
|
|
@ -88,7 +88,9 @@ futoji.addTransformer({
|
||||||
let formatted = formatCode(unescapeHTML(text))
|
let formatted = formatCode(unescapeHTML(text))
|
||||||
|
|
||||||
let highlighted
|
let highlighted
|
||||||
if(formatted.lang in hljs.listLanguages()) {
|
if(formatted.lang.length === 0) {
|
||||||
|
return `<div class="codeblock"><code>${escapeHTML(formatted.code)}</code></div>`
|
||||||
|
} else if(hljs.listLanguages().includes(formatted.lang)) {
|
||||||
highlighted = hljs.highlight(formatted.lang, formatted.code, true)
|
highlighted = hljs.highlight(formatted.lang, formatted.code, true)
|
||||||
} else {
|
} else {
|
||||||
highlighted = hljs.highlightAuto(formatted.code)
|
highlighted = hljs.highlightAuto(formatted.code)
|
||||||
|
|
@ -134,7 +136,7 @@ function formatCode(text) {
|
||||||
|
|
||||||
return {
|
return {
|
||||||
lang: '',
|
lang: '',
|
||||||
code: text
|
code: text.replace(/^\n/, '')
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue