Skip to content

Commit 379529c

Browse files
committed
chore: upgrade marked to v14
1 parent 7896cfa commit 379529c

File tree

4 files changed

+47
-31
lines changed

4 files changed

+47
-31
lines changed

app/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,8 @@
2929
"dayjs": "^1.11.13",
3030
"highlight.js": "^11.10.0",
3131
"lodash": "^4.17.21",
32-
"marked": "^10.0.0",
32+
"marked": "^14.1.2",
33+
"marked-highlight": "^2.1.4",
3334
"nprogress": "^0.2.0",
3435
"pinia": "^2.2.4",
3536
"pinia-plugin-persistedstate": "^4.1.1",

app/pnpm-lock.yaml

Lines changed: 32 additions & 20 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

app/src/components/ChatGPT/ChatGPT.vue

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
<script setup lang="ts">
22
import Icon, { SendOutlined } from '@ant-design/icons-vue'
33
import { storeToRefs } from 'pinia'
4-
import { marked } from 'marked'
4+
import { Marked } from 'marked'
55
import hljs from 'highlight.js'
6+
import { markedHighlight } from 'marked-highlight'
67
import type { Ref } from 'vue'
78
import { urlJoin } from '@/lib/helper'
89
import { useSettingsStore, useUserStore } from '@/pinia'
@@ -158,17 +159,17 @@ async function send() {
158159
await request()
159160
}
160161
161-
const renderer = new marked.Renderer()
162+
const marked = new Marked(
163+
markedHighlight({
164+
langPrefix: 'hljs language-',
165+
highlight(code, lang) {
166+
const language = hljs.getLanguage(lang) ? lang : 'nginx'
162167
163-
renderer.code = (code, lang: string) => {
164-
const language = hljs.getLanguage(lang) ? lang : 'nginx'
165-
const highlightedCode = hljs.highlight(code, { language }).value
166-
167-
return `<pre><code class="hljs ${language}">${highlightedCode}</code></pre>`
168-
}
168+
return hljs.highlight(code, { language }).value
169+
},
170+
}))
169171
170172
marked.setOptions({
171-
renderer,
172173
pedantic: false,
173174
gfm: true,
174175
breaks: false,

app/src/views/environment/BatchUpgrader.vue

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,9 @@ function log(msg: string) {
4040
4141
logContainer.value.appendChild(para)
4242
43-
logContainer.value.scroll({ top: 320, left: 0, behavior: 'smooth' })
43+
nextTick(() => {
44+
logContainer.value.scroll({ top: logContainer.value.scrollHeight, left: 0, behavior: 'smooth' })
45+
})
4446
}
4547
4648
const progressPercentComputed = computed(() => {

0 commit comments

Comments
 (0)