Skip to content

Commit

Permalink
chore: upgrade marked to v14
Browse files Browse the repository at this point in the history
  • Loading branch information
0xJacky committed Oct 8, 2024
1 parent 7896cfa commit 379529c
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 31 deletions.
3 changes: 2 additions & 1 deletion app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@
"dayjs": "^1.11.13",
"highlight.js": "^11.10.0",
"lodash": "^4.17.21",
"marked": "^10.0.0",
"marked": "^14.1.2",
"marked-highlight": "^2.1.4",
"nprogress": "^0.2.0",
"pinia": "^2.2.4",
"pinia-plugin-persistedstate": "^4.1.1",
Expand Down
52 changes: 32 additions & 20 deletions app/pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

19 changes: 10 additions & 9 deletions app/src/components/ChatGPT/ChatGPT.vue
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
<script setup lang="ts">
import Icon, { SendOutlined } from '@ant-design/icons-vue'
import { storeToRefs } from 'pinia'
import { marked } from 'marked'
import { Marked } from 'marked'
import hljs from 'highlight.js'
import { markedHighlight } from 'marked-highlight'
import type { Ref } from 'vue'
import { urlJoin } from '@/lib/helper'
import { useSettingsStore, useUserStore } from '@/pinia'
Expand Down Expand Up @@ -158,17 +159,17 @@ async function send() {
await request()
}
const renderer = new marked.Renderer()
const marked = new Marked(
markedHighlight({
langPrefix: 'hljs language-',
highlight(code, lang) {
const language = hljs.getLanguage(lang) ? lang : 'nginx'
renderer.code = (code, lang: string) => {
const language = hljs.getLanguage(lang) ? lang : 'nginx'
const highlightedCode = hljs.highlight(code, { language }).value
return `<pre><code class="hljs ${language}">${highlightedCode}</code></pre>`
}
return hljs.highlight(code, { language }).value
},
}))
marked.setOptions({
renderer,
pedantic: false,
gfm: true,
breaks: false,
Expand Down
4 changes: 3 additions & 1 deletion app/src/views/environment/BatchUpgrader.vue
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,9 @@ function log(msg: string) {
logContainer.value.appendChild(para)
logContainer.value.scroll({ top: 320, left: 0, behavior: 'smooth' })
nextTick(() => {
logContainer.value.scroll({ top: logContainer.value.scrollHeight, left: 0, behavior: 'smooth' })
})
}
const progressPercentComputed = computed(() => {
Expand Down

0 comments on commit 379529c

Please sign in to comment.