0.5.0 • Published 4 years ago

mathjax-dom v0.5.0

Weekly downloads
1
License
MIT
Repository
github
Last release
4 years ago

MathJax DOM npm.io npm.io npm CircleCI

Prerenders all math equations over an entire HTML string using MathJax.

API

/**
 * Parses an HTML string and prerenders all math equations using MathJax.
 *
 * @param {String} htmlString - HTML string to process.
 * @param {Object} [pageOptions] - Options for [`mathjax-node-page`](https://github.com/pkra/mathjax-node-page)'s
 *                                 `mjpageConfig` object.
 * @param {Object} [nodeOptions] - Options for [`mathjax-node-page`](https://github.com/pkra/mathjax-node-page)'s
 *                                 `mjnodeConfig` object.
 *
 * @return {Promise<String>} - Promise with the output HTML string as the
 *                             fulfillment value.
 */
function mathjaxDOM(htmlString, pageOptions, nodeOptions)

Usage

This module crawls the HTML string for delimiters \( ... \) and $$ ... $$. You can override this in options.

Example:

const mathjaxDOM = require('mathjax-dom');

mathjaxDOM(`<some_html>`)
  .then(htmlString => {
    // The output HTML string with all math equations prerendered.
    console.log(htmlString);
  })
  .catch(err => {
    throw err;
  });
});

Disclaimer

This is an experimental project driven by internal requirements.