markdown-it-simplemath

1.0.0 • Public • Published

Build Status NPM version Coverage Status

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$'));

Dependents (0)

Package Sidebar

Install

npm i markdown-it-simplemath

Weekly Downloads

0

Version

1.0.0

License

MIT

Last publish

Collaborators

  • adam-p