Skip to content

Commit

Permalink
Fix info add latex
Browse files Browse the repository at this point in the history
  • Loading branch information
dark-flames committed Mar 21, 2018
1 parent cc48acb commit 13ee97f
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 1 deletion.
2 changes: 1 addition & 1 deletion package-lock.json

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

12 changes: 12 additions & 0 deletions src/components/plugin/MarkdownParser.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import 'highlight.js/styles/tomorrow.css'
import 'katex/dist/katex.css'
import Highlight from './Highlight'
import escapeHtml from 'escape-html'
import katex from 'katex/dist/katex'

export function MarkdownParser (code, stringMap) {
const marked = require('marked')
Expand All @@ -20,6 +22,16 @@ export function MarkdownParser (code, stringMap) {
code = code.replace(mapItem.hash, mapItem.segment)
})

if (lang === 'latex') {
try {
return katex.renderToString(code, {
displayMode: true
})
} catch (exception) {
return code
}
}

const out = highlight(code, lang)
if (out !== null) {
code = out
Expand Down
4 changes: 4 additions & 0 deletions src/components/toolbar-button/btn-code.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,10 @@ export default {
title: 'php',
value: 'php'
},
{
title: 'latex',
value: 'latex'
},
{
title: '未选择',
value: ''
Expand Down
1 change: 1 addition & 0 deletions src/components/toolbar-button/btn-info.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ export default {
action: {
insert () {
window.location.href = 'https://github.com/luogu-dev/markdown-palettes'
return ''
}
}
}

0 comments on commit 13ee97f

Please sign in to comment.