Published
Edited
Oct 5, 2019
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
mml = tex2MathML(expression);
Insert cell
Insert cell
Insert cell
jsonML = mathML2Json(mml);
Insert cell
Insert cell
Insert cell
tex2MathML = (tex, inline = true) => {
return katex.renderToString(tex, {
displayMode: !inline,
output: "mathml"
});
}
Insert cell
tex2Span = (tex, inline = true) => {
return katex.renderToString(tex, {
displayMode: !inline,
output: "html"
});
}
Insert cell
mathML2Json = (mathML) => {
return onml.parse(mathML).splice(2, 1);
};
Insert cell
htmlBeautify = (html) => {
return jsBeautify.html(html, {
indent_size: 2,
end_with_newline: true,
preserve_newlines: false,
max_preserve_newlines: 0,
wrap_line_length: 0,
wrap_attributes_indent_size: 0,
unformatted: ['mi', 'mn', 'mo']
});
}
Insert cell
Insert cell
katex = require('katex@0.11.1/dist/katex.js');
Insert cell
html`
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/katex@0.11.1/dist/katex.min.css" integrity="sha384-zB1R0rpPzHqg7Kpt0Aljp8JPLqbXI3bhnPWROx27a9N0Ll6ZP/+DiW/UqRcLbRjq" crossorigin="anonymous">
`
Insert cell
onml = require('onml@1.1.0/build/onml.js')
Insert cell
jsBeautify = require('https://bundle.run/js-beautify@1.10.2');
Insert cell
jsonBeautify = require('https://bundle.run/json-beautify@1.1.1');
Insert cell

Purpose-built for displays of data

Observable is your go-to platform for exploring data and creating expressive data visualizations. Use reactive JavaScript notebooks for prototyping and a collaborative canvas for visual data exploration and dashboard creation.
Learn more