Public
Edited
Apr 28, 2024
Insert cell
Insert cell
Insert cell
__exp = renderExpression(__testExpression)
Insert cell
function* renderExpression(expressionText) {
// const expressionSvg = text2Svg(expressionText);
// const container = htl.html`
// <div style="
// display: flex;
// justify-content: center;
// align-items: center;
// padding: 1em;
// font-size: 300%;
// ">${expressionSvg}</div>`;

// yield container;

// const svg = d3.select(expressionSvg);
// const yOffset = Math.abs(parseInt(svg.attr("viewBox").split(" ")[1]));
// const math = svg.select(`[${MML_NODE_ATTR}="math"]`);
// const hitBoxContainer = math.append("g").classed("hit-boxes", true);

// math.selectAll(`[${MML_NODE_ATTR}]`).each(function () {
// applyInteraction(d3.select(this), hitBoxContainer, yOffset);
// });
}
Insert cell
Insert cell
mmlXml = text2MmlJson(__testExpression)
Insert cell
Insert cell
//MathJax.mathml2svg(jsonToXml(mmlXmlSwapped))
Insert cell
swapParams = (node) => {
const [a, op, b] = Object.keys(node);
return { [b]: node[b], [op]: node[op], [a]: node[a] };
}
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
//MathJax.startup.toMML(MathJax.startup.output)
Insert cell
Insert cell
Insert cell
// _MathJax = require("https://cdn.jsdelivr.net/npm/mathjax@3/es5/mml-svg.js").catch(
// () => {
// const mathml2svg = window.MathJax.mathml2svg;
// delete window.MathJax;
// return require("https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-svg.js").catch(
// () => {
// const tex2svg = window.MathJax.tex2svg;
// const tex2mml = window.MathJax.tex2mml;

// delete window.MathJax;
// return { mathml2svg, tex2svg, tex2mml };
// }
// );
// }
// )
Insert cell
Insert cell
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