mathjax-parser
Version:
Find & Replace the mathjax delimiters in a HTML string
37 lines (27 loc) • 1.18 kB
Markdown
[](https://travis-ci.org/bersling/mathjax-parser)
A simple mathjax parser in order to find and replace occurences of mathjax in a HTML String. No Jquery. Zero Regex. 0 Code Warnings. 10+ unit tests.
```
npm install --save mathjax-parser
```
```
var parser = new MathjaxParser();
parser.parse(demoString).outputHtml;
```
See the demo.html or the [plunker](https://embed.plnkr.co/h84SUO5jzUayIIEYSfum/).
Running the parser without a configuration is a bit pointless. Provide it with a config that looks like this:
```
var parser = new MathjaxParser();
var config = {
inlineMath: [['$','$'],['\\(','\\)']],
displayMath: [['$$','$$'],['\\[','\\]']],
inlineMathReplacement: ['XXX', 'XXX'],
displayMathReplacement: ['YYY','ZZZ']
}
parser.parse(demoString, config).outputHtml;
```
A description of the building-and-thought-process of the parser can be found here: https://www.bersling.com/2017/01/22/mathjax-parser-for-html-strings/