feat: KaTeX support

This commit is contained in:
Liu Jiangyi
2020-06-22 18:09:46 +08:00
parent e984dfeccb
commit 01225a3695
3 changed files with 13 additions and 1 deletions

View File

@@ -25,7 +25,7 @@
"deploy": "gh-pages -d build -m $(TZ=Asia/Shanghai date +\"%y%m%d%H%M%S\")",
"eject": "react-scripts eject"
},
"homepage": "https://://cdn.jsdelivr.net/gh/thuhole/webhole@gh-pages",
"homepage": "https://cdn.jsdelivr.net/gh/thuhole/webhole@gh-pages",
"browserslist": {
"production": [
">0.2%",

View File

@@ -64,6 +64,12 @@ export class HighlightedMarkdown extends Component {
const props = this.props
const processDefs = new HtmlToReact.ProcessNodeDefinitions(React)
const processInstructions = [
{
shouldProcessNode: (node) => node.name === 'img',
processNode (node) {
return (<div>[图片]</div>)
}
},
{
shouldProcessNode (node) {
return node.type === 'text' // pid, nickname, search

View File

@@ -1,8 +1,14 @@
import MarkdownIt from 'markdown-it'
import MarkdownItKaTeX from 'markdown-it-katex'
import 'katex/dist/katex.min.css'
let md = new MarkdownIt({
html: false,
linkify: false
}).use(MarkdownItKaTeX, {
"throwOnError" : false,
"errorColor" : "#aa0000"
})
export default (text) => md.render(text)