forked from newthuhole/hole_thu_frontend
feat: KaTeX support
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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)
|
||||
Reference in New Issue
Block a user