forked from newthuhole/hole_thu_frontend
feat: KaTeX support
This commit is contained in:
@@ -25,7 +25,7 @@
|
|||||||
"deploy": "gh-pages -d build -m $(TZ=Asia/Shanghai date +\"%y%m%d%H%M%S\")",
|
"deploy": "gh-pages -d build -m $(TZ=Asia/Shanghai date +\"%y%m%d%H%M%S\")",
|
||||||
"eject": "react-scripts eject"
|
"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": {
|
"browserslist": {
|
||||||
"production": [
|
"production": [
|
||||||
">0.2%",
|
">0.2%",
|
||||||
|
|||||||
@@ -64,6 +64,12 @@ export class HighlightedMarkdown extends Component {
|
|||||||
const props = this.props
|
const props = this.props
|
||||||
const processDefs = new HtmlToReact.ProcessNodeDefinitions(React)
|
const processDefs = new HtmlToReact.ProcessNodeDefinitions(React)
|
||||||
const processInstructions = [
|
const processInstructions = [
|
||||||
|
{
|
||||||
|
shouldProcessNode: (node) => node.name === 'img',
|
||||||
|
processNode (node) {
|
||||||
|
return (<div>[图片]</div>)
|
||||||
|
}
|
||||||
|
},
|
||||||
{
|
{
|
||||||
shouldProcessNode (node) {
|
shouldProcessNode (node) {
|
||||||
return node.type === 'text' // pid, nickname, search
|
return node.type === 'text' // pid, nickname, search
|
||||||
|
|||||||
@@ -1,8 +1,14 @@
|
|||||||
import MarkdownIt from 'markdown-it'
|
import MarkdownIt from 'markdown-it'
|
||||||
|
import MarkdownItKaTeX from 'markdown-it-katex'
|
||||||
|
|
||||||
|
import 'katex/dist/katex.min.css'
|
||||||
|
|
||||||
let md = new MarkdownIt({
|
let md = new MarkdownIt({
|
||||||
html: false,
|
html: false,
|
||||||
linkify: false
|
linkify: false
|
||||||
|
}).use(MarkdownItKaTeX, {
|
||||||
|
"throwOnError" : false,
|
||||||
|
"errorColor" : "#aa0000"
|
||||||
})
|
})
|
||||||
|
|
||||||
export default (text) => md.render(text)
|
export default (text) => md.render(text)
|
||||||
Reference in New Issue
Block a user