allow KaTeX options
This commit is contained in:
parent
3e7261b90a
commit
1922f1d732
3 changed files with 14 additions and 4 deletions
|
@ -43,6 +43,11 @@ If you're using the default markdown-it parser, I also recommend the [github sty
|
|||
<link rel="stylesheet" href="https://cdn.jsdelivr.net/github-markdown-css/2.2.1/github-markdown.css"/>
|
||||
```
|
||||
|
||||
`KaTeX` options can be supplied with the second argument to use.
|
||||
```javascript
|
||||
md.use(mk, {"throwOnError" : false, "errorColor" : " #cc0000"});
|
||||
```
|
||||
|
||||
## Examples
|
||||
|
||||
### Inline
|
||||
|
|
11
index.js
11
index.js
|
@ -220,16 +220,20 @@ function makeMath_block(open, close) {
|
|||
}
|
||||
|
||||
|
||||
module.exports = function math_plugin(md) {
|
||||
module.exports = function math_plugin(md, options) {
|
||||
// Default options
|
||||
|
||||
var inlineOpen = '$',
|
||||
inlineClose = '$',
|
||||
blockOpen = '$$',
|
||||
blockClose = '$$';
|
||||
|
||||
options = options || {};
|
||||
|
||||
// set KaTeX as the renderer for markdown-it-simplemath
|
||||
var katexInline = function(latex){
|
||||
return katex.renderToString(latex, {"displayMode" : false});
|
||||
options.displayMode = false;
|
||||
return katex.renderToString(latex, options);
|
||||
};
|
||||
|
||||
var inlineRenderer = function(tokens, idx){
|
||||
|
@ -237,7 +241,8 @@ module.exports = function math_plugin(md) {
|
|||
};
|
||||
|
||||
var katexBlock = function(latex){
|
||||
return katex.renderToString(latex, {"displayMode" : true});
|
||||
options.displayMode = true;
|
||||
return katex.renderToString(latex, options);
|
||||
}
|
||||
|
||||
var blockRenderer = function(tokens, idx){
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "markdown-it-katex",
|
||||
"version": "1.0.9",
|
||||
"version": "1.1.0",
|
||||
"description": "Fast math support for markdown-it with KaTeX",
|
||||
"main": "index.js",
|
||||
"scripts": {
|
||||
|
|
Reference in a new issue