MCPcopy Index your code
hub / github.com/TruthHun/BookStack / buildMathML

Function buildMathML

static/katex/katex.mjs:6969–6992  ·  view source on GitHub ↗

* Takes a full parse tree and settings and builds a MathML representation of * it. In particular, we put the elements from building the parse tree into a * tag so we can also include that TeX source as an annotation. * * Note that we actually return a domTree element with a ` `

(tree, texExpression, options)

Source from the content-addressed store, hash-verified

6967 */
6968
6969function buildMathML(tree, texExpression, options) {
6970 const expression = buildExpression$1(tree, options); // Wrap up the expression in an mrow so it is presented in the semantics
6971 // tag correctly, unless it's a single <mrow> or <mtable>.
6972
6973 let wrapper;
6974
6975 if (expression.length === 1 && expression[0] instanceof MathNode && utils.contains(["mrow", "mtable"], expression[0].type)) {
6976 wrapper = expression[0];
6977 } else {
6978 wrapper = new mathMLTree.MathNode("mrow", expression);
6979 } // Build a TeX annotation of the source
6980
6981
6982 const annotation = new mathMLTree.MathNode("annotation", [new mathMLTree.TextNode(texExpression)]);
6983 annotation.setAttribute("encoding", "application/x-tex");
6984 const semantics = new mathMLTree.MathNode("semantics", [wrapper, annotation]);
6985 const math = new mathMLTree.MathNode("math", [semantics]); // You can't style <math> nodes, so we wrap the node in a span.
6986 // NOTE: The span class is not typed to have <math> nodes as children, and
6987 // we don't want to make the children type more generic since the children
6988 // of span are expected to have more fields in `buildHtml` contexts.
6989 // $FlowFixMe
6990
6991 return buildCommon.makeSpan(["katex-mathml"], [math]);
6992}
6993
6994const optionsFromSettings = function optionsFromSettings(settings) {
6995 return new Options({

Callers 1

buildTreeFunction · 0.70

Calls 2

setAttributeMethod · 0.95
buildExpression$1Function · 0.85

Tested by

no test coverage detected