Skip to content

Commit 13ee97f

Browse files
committed
Fix info add latex
1 parent cc48acb commit 13ee97f

File tree

4 files changed

+18
-1
lines changed

4 files changed

+18
-1
lines changed

package-lock.json

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/components/plugin/MarkdownParser.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
import 'highlight.js/styles/tomorrow.css'
2+
import 'katex/dist/katex.css'
23
import Highlight from './Highlight'
34
import escapeHtml from 'escape-html'
5+
import katex from 'katex/dist/katex'
46

57
export function MarkdownParser (code, stringMap) {
68
const marked = require('marked')
@@ -20,6 +22,16 @@ export function MarkdownParser (code, stringMap) {
2022
code = code.replace(mapItem.hash, mapItem.segment)
2123
})
2224

25+
if (lang === 'latex') {
26+
try {
27+
return katex.renderToString(code, {
28+
displayMode: true
29+
})
30+
} catch (exception) {
31+
return code
32+
}
33+
}
34+
2335
const out = highlight(code, lang)
2436
if (out !== null) {
2537
code = out

src/components/toolbar-button/btn-code.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,10 @@ export default {
4040
title: 'php',
4141
value: 'php'
4242
},
43+
{
44+
title: 'latex',
45+
value: 'latex'
46+
},
4347
{
4448
title: '未选择',
4549
value: ''

src/components/toolbar-button/btn-info.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ export default {
55
action: {
66
insert () {
77
window.location.href = 'https://github.com/luogu-dev/markdown-palettes'
8+
return ''
89
}
910
}
1011
}

0 commit comments

Comments
 (0)