added syntax highlighting

This commit is contained in:
brecert 2019-11-12 18:00:13 -05:00
parent 524651d566
commit 7ea9bb37a5
2 changed files with 8 additions and 2 deletions

View file

@ -21,7 +21,6 @@
<div class="username" @click="openUserInformation">{{ this.$props.username }}</div>
<div class="date">{{ getDate }}</div>
</div>
<!-- <div class="content-message" v-html="formatMessage" /> -->
<SimpleMarkdown class="content-message" :message="message" />
<div class="file-content" v-if="getFile">
<div class="icon">

View file

@ -1,4 +1,5 @@
import * as SimpleMarkdown from 'simple-markdown'
import hljs from 'highlight.js'
export default (order) => { return {
order: order++,
@ -16,7 +17,13 @@ export default (order) => { return {
html: function(node, output) {
const className = node.lang ? `language-${node.lang}` : undefined
const codeblock = SimpleMarkdown.htmlTag("div", SimpleMarkdown.sanitizeText(node.content), {
let content = SimpleMarkdown.sanitizeText(node.content)
if(node.lang) {
content = hljs.highlight(node.lang, node.content, true).value
}
const codeblock = SimpleMarkdown.htmlTag("div", content, {
class: "codeblock"
})