mirror of
https://github.com/danbulant/Nertivia-Client
synced 2026-06-24 17:11:43 +00:00
added syntax highlighting
This commit is contained in:
parent
524651d566
commit
7ea9bb37a5
2 changed files with 8 additions and 2 deletions
|
|
@ -21,7 +21,6 @@
|
||||||
<div class="username" @click="openUserInformation">{{ this.$props.username }}</div>
|
<div class="username" @click="openUserInformation">{{ this.$props.username }}</div>
|
||||||
<div class="date">{{ getDate }}</div>
|
<div class="date">{{ getDate }}</div>
|
||||||
</div>
|
</div>
|
||||||
<!-- <div class="content-message" v-html="formatMessage" /> -->
|
|
||||||
<SimpleMarkdown class="content-message" :message="message" />
|
<SimpleMarkdown class="content-message" :message="message" />
|
||||||
<div class="file-content" v-if="getFile">
|
<div class="file-content" v-if="getFile">
|
||||||
<div class="icon">
|
<div class="icon">
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
import * as SimpleMarkdown from 'simple-markdown'
|
import * as SimpleMarkdown from 'simple-markdown'
|
||||||
|
import hljs from 'highlight.js'
|
||||||
|
|
||||||
export default (order) => { return {
|
export default (order) => { return {
|
||||||
order: order++,
|
order: order++,
|
||||||
|
|
@ -16,7 +17,13 @@ export default (order) => { return {
|
||||||
html: function(node, output) {
|
html: function(node, output) {
|
||||||
const className = node.lang ? `language-${node.lang}` : undefined
|
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"
|
class: "codeblock"
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue