markdown-it-simplemath
v1.0.0
Published
markdown-it plugin that adds simple math support
Downloads
1
Maintainers
Readme
markdown-it-simplemath
This is a markdown-it plugin that adds simple math support. It is up to the caller to supply a rendering function.
NOTE: For fully featured math rendering, you should use runarberg/markdown-it-math. This plugin was created for a particular need to render to images. It really just passes off whatever is inside $...$
to an external renderer.
Originally developed for use with Markdown Here.
Installation
$ npm install markdown-it-simplemath
Usage
var md = require('markdown-it')();
var mathRenderer = function(mathStr) {
return '<img src="https://chart.googleapis.com/chart?cht=tx&chl={urlmathcode}" alt="{mathcode}">'
.replace(/\{mathcode\}/ig, mathcode)
.replace(/\{urlmathcode\}/ig, encodeURIComponent(mathcode));
};
md.use(require('markdown-it-simplemath'), {inlineRenderer: mathRenderer});
console.log(md.render('$x \over y$'));