MathJax Wrapper for Dart

A very basic set of wrapper functions for using the MathJax javascript display engine for mathematics in Dart.

Basic Usage

MathJax crawls through the document and processes the LaTeX and MathML present inside '\\]' and '\\]' tags.

For example, it will convert the latex from the following

<div>
  \[
    \begin{equation}
      A = \pi r^2
    \end{equation}
  \]
<\div>

to a beautifully typeset equation.

Initialization and Static Processing

The package must be initialized to use. This imports the javascript file and processes the content present at the time.

mathJaxInit();

Processing Dynamically Inserted Elements

Subsequent calls to mathJaxInit() will not update content added after the initial call. To have MathJax process dynamically added elements, use

mathJaxProcess([element]);

where element can be: 1. dart elements; 2. element id strings (without the #); 3. a list where each element is either of the above; or 4. null/empty, in which case the entire document is processed.

Note: there are more optional arguments to mathJaxProcess for rare occurances - see documentation for full details.

Helper functions

At the moment, there is a single helper function,

String latexEquation(String s)

which adds the '\\' and '\\' needed by MathJax, and \\begin{equation} and \\end{equation} used in LaTeX around the String s.

See also

MathJax

LaTeX

MathML

Author

Dominic Jack

[email protected]

Feel free to contact me with issues, bug reports, suggestions, or if you'd like to expand on this minimalist base.

Note: Just to be clear, these author details are for the wrapper only. MathJax, MathML and LaTeX are large projects that have been running for quite some time, and I have no involvement with any.

Libraries

math_jax_wrapper

A very simple package to wrap calls to MathJax. mathJaxInit should be called once to import the relevant MathJax script. After this, mathJaxProcess can be called to process either the entire document or a subset of elements - necessary to update dynamic changes after initialization.