README
MathJax3 - React
React component to easily load MathJax v3 and process dynamically raw ASCIIMath, TeX or MathML content.
Installation
NPM:
npm install mathjax3-react --save
YARN:
yarn add mathjax3-react
Basic usage
From HTML String
import React from "react";
import MathJax from "mathjax3-react";
function App() {
return (
<div className="App">
<MathJax.Provider>
<MathJax.Html html={html}/>
</MathJax.Provider>
</div>
);
}
HTML string:
const html = `
<p>Let's analise this equation:</p>
<p style="text-align:center;">
<math xmlns="http://www.w3.org/1998/Math/MathML" display="block">
<msup>
<mrow>
<mi>r</mi>
</mrow>
<mrow>
<mn>2</mn>
</mrow>
</msup>
<mo>+</mo>
<msup>
<mrow>
<mi>z</mi>
</mrow>
<mrow>
<mn>2</mn>
</mrow>
</msup>
<mo>=</mo>
<mn>4</mn>
</math>
</p>
`;
Result:
TeX or AsciiMath formula
import React from "react";
import MathJax from "mathjax3-react";
function basicUsage() {
return (
<div className="App">
<MathJax.Provider>
<MathJax.Formula formula="$\int x^2dx$" />
</MathJax.Provider>
</div>
);
}
export default basicUsage;
Result:
Custom options
You can set custom script url or MathJax by sending them as props to MathJax.Provider
component
import React from "react";
import MathJax from "mathjax3-react";
function customOptions() {
return (
<div className="App">
<MathJax.Provider
url="https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-chtml.js"
options={{
tex: {
inlineMath: [['