Skip to content

Commit

Permalink
Merge pull request #845 from TurboSlayer/master
Browse files Browse the repository at this point in the history
Updated katex math support to a newer package (markdown-it-texmath)
  • Loading branch information
joemccann committed Nov 28, 2022
2 parents 3985d4a + af5aad4 commit 502b0c6
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 21 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@
"markdown-it-math": "^3.0.2",
"markdown-it-sub": "^1.0.0",
"markdown-it-sup": "^1.0.0",
"markdown-it-texmath": "^1.0.0",
"markdown-it-toc": "^1.1.0",
"md-to-pdf": "^5.0.0",
"medium-sdk": "0.0.4",
Expand Down
24 changes: 5 additions & 19 deletions plugins/core/markdown-it.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,25 +12,6 @@ const md = require('markdown-it')({
}
}
})
/*
change to Katex for math rendering
*/
md.use(require('markdown-it-math'), {
inlineRenderer: function (str) {
try {
return '<span class="math inline">' + katex.renderToString(str) + '</span>'
} catch (e) {
return '<span class="math inline">' + e + '</span>'
}
},
blockRenderer: function (str) {
try {
return '<span class="math block">' + katex.renderToString(str) + '</span>'
} catch (e) {
return '<span class="math block">' + e + '</span>'
}
}
})

md
.use(require('markdown-it-toc'))
Expand All @@ -42,6 +23,11 @@ md
.use(require('markdown-it-ins'))
.use(require('markdown-it-abbr'))
.use(require('markdown-it-checkbox'))
.use(require('markdown-it-texmath'), {
engine: require('katex'),
delimiters: 'dollars'
})


md.renderer.rules.table_open = function (
tokens, idx, options, env, self
Expand Down
2 changes: 1 addition & 1 deletion public/css/app.css

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion public/css/export.css

Large diffs are not rendered by default.

0 comments on commit 502b0c6

Please sign in to comment.