减少 hljs 的体积
This commit is contained in:
@@ -57,7 +57,7 @@ function addButton() {
|
|||||||
const match = code.className.match(/-(.*)/)
|
const match = code.className.match(/-(.*)/)
|
||||||
let lang = "html"
|
let lang = "html"
|
||||||
if (match) lang = match[1].toLowerCase()
|
if (match) lang = match[1].toLowerCase()
|
||||||
copy.innerHTML = `<span class="lang">${lang}</span><div class="btn">替换<div>`
|
copy.innerHTML = `<span class="lang">${lang.toUpperCase()}</span><div class="btn">替换<div>`
|
||||||
const btn = copy.children[1] as HTMLDivElement
|
const btn = copy.children[1] as HTMLDivElement
|
||||||
btn.onclick = () => {
|
btn.onclick = () => {
|
||||||
tab.value = lang
|
tab.value = lang
|
||||||
@@ -144,5 +144,6 @@ watch(step, render)
|
|||||||
padding: 1rem;
|
padding: 1rem;
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
border-radius: 0.4rem;
|
border-radius: 0.4rem;
|
||||||
|
font-size: 1rem;
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|||||||
20
src/main.ts
20
src/main.ts
@@ -1,18 +1,28 @@
|
|||||||
import { createApp } from "vue"
|
import { createApp } from "vue"
|
||||||
import { create } from "naive-ui"
|
import { create } from "naive-ui"
|
||||||
import { marked } from "marked"
|
import App from "./App.vue"
|
||||||
|
|
||||||
//@ts-ignore
|
//@ts-ignore
|
||||||
import "normalize.css"
|
import "normalize.css"
|
||||||
//@ts-ignore
|
//@ts-ignore
|
||||||
import "github-markdown-css/github-markdown-light.css"
|
import "github-markdown-css/github-markdown-light.css"
|
||||||
//@ts-ignore
|
|
||||||
import "highlight.js/styles/github.min.css"
|
import { marked } from "marked"
|
||||||
import App from "./App.vue"
|
|
||||||
import markedAlert from "marked-alert"
|
import markedAlert from "marked-alert"
|
||||||
import { markedHighlight } from "marked-highlight"
|
import { markedHighlight } from "marked-highlight"
|
||||||
import hljs from "highlight.js"
|
|
||||||
import { alertVariants } from "./utils"
|
import { alertVariants } from "./utils"
|
||||||
|
|
||||||
|
import hljs from "highlight.js/lib/core"
|
||||||
|
import xml from "highlight.js/lib/languages/xml"
|
||||||
|
import css from "highlight.js/lib/languages/css"
|
||||||
|
import javascript from "highlight.js/lib/languages/javascript"
|
||||||
|
//@ts-ignore
|
||||||
|
import "highlight.js/styles/github.min.css"
|
||||||
|
|
||||||
|
hljs.registerLanguage("html", xml)
|
||||||
|
hljs.registerLanguage("css", css)
|
||||||
|
hljs.registerLanguage("js", javascript)
|
||||||
|
|
||||||
marked.use({
|
marked.use({
|
||||||
gfm: true,
|
gfm: true,
|
||||||
async: true,
|
async: true,
|
||||||
|
|||||||
Reference in New Issue
Block a user