add code highlighting

This commit is contained in:
Dwsy
2023-02-15 11:07:21 +08:00
committed by Redon
parent 79dd6c5e18
commit 8dab963628
9 changed files with 88 additions and 95 deletions

View File

@@ -3,7 +3,8 @@ import App from './App.vue'
import { setupAssets } from '@/plugins'
import { setupStore } from '@/store'
import { setupRouter } from '@/router'
import hljs from 'highlight.js'
import "highlight.js/styles/xcode.css"
async function bootstrap() {
const app = createApp(App)
setupAssets()
@@ -12,6 +13,15 @@ async function bootstrap() {
await setupRouter(app)
let regexp = /^(?:\s{4}|\t).+/gm
app.directive('hljs', {
mounted: (el: HTMLElement) => {
if (el.textContent?.indexOf(" = ") != -1 || el.textContent.match(regexp)) {
hljs.highlightBlock(el)
}
}
})
app.mount('#app')
}