JSPM

@pythonnut/react-mathjax

0.1.6
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 1
  • Score
    100M100P100Q15859F
  • License MIT

React component for MathJax

Package Exports

  • @pythonnut/react-mathjax

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@pythonnut/react-mathjax) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

React MathJax

(experimental)

React component to display math formulas written in AsciiMath or TeX.

Example of usage

Based on the react-mathjax from SamyPesse. The main difference is in updated deps, syntax and extended options (delay of rendering and support for AsciiMath).

How to install

npm install @matejmazur/react-mathjax

How to use

const MathJax = require('@matejmazur/react-mathjax')
const ascii = 'U = 1/(R_(si) + sum_(i=1)^n(s_n/lambda_n) + R_(se))'
const tex = `f(x) = \\int_{-\\infty}^\\infty\\hat f(\\xi)\\,e^{2 \\pi i \\xi x}\\,d\\xi`

module.exports = () => {
    return (
        <div>
            <MathJax.Context>
                <div>
                    This is an inline math formula: <MathJax.Node inline>{'a = b'}</MathJax.Node>
                    And a block one:

                    <MathJax.Node>{ascii}</MathJax.Node>
                </div>
            </MathJax.Context>

            <MathJax.Context input='tex'>
                <div>
                    This is an inline math formula: <MathJax.Node inline>{'a = b'}</MathJax.Node>
                    And a block one:

                    <MathJax.Node>{tex}</MathJax.Node>
                </div>
            </MathJax.Context>
        </div>
    );
}

API

MathJax.Context props

script (String)

  • Loads specified link with MathJax library.
  • Default: https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.1/MathJax.js?config=TeX-MML-AM_CHTML

input (String)

  • Sets type of input.
  • Options: tex | ascii
  • Default: ascii

delay (Number)

  • Sets delay between updates.
  • Default: 0 (the main difference between this library and react-mathjax from SamyPesse)

options (Object)

Acknowledgements

License

This project is licensed under the MIT License - see the LICENSE.md file for details.