UNPKG

1.35 kBJavaScriptView Raw
1// @flow
2import {defineFunctionBuilders} from "../defineFunction";
3import mathMLTree from "../mathMLTree";
4
5import * as mml from "../buildMathML";
6
7const pad = () => {
8 const padNode = new mathMLTree.MathNode("mtd", []);
9 padNode.setAttribute("width", "50%");
10 return padNode;
11};
12
13defineFunctionBuilders({
14 type: "tag",
15 mathmlBuilder(group, options) {
16 const table = new mathMLTree.MathNode("mtable", [
17 new mathMLTree.MathNode("mtr", [
18 pad(),
19 new mathMLTree.MathNode("mtd", [
20 mml.buildExpressionRow(group.body, options),
21 ]),
22 pad(),
23 new mathMLTree.MathNode("mtd", [
24 mml.buildExpressionRow(group.tag, options),
25 ]),
26 ]),
27 ]);
28 table.setAttribute("width", "100%");
29 return table;
30
31 // TODO: Left-aligned tags.
32 // Currently, the group and options passed here do not contain
33 // enough info to set tag alignment. `leqno` is in Settings but it is
34 // not passed to Options. On the HTML side, leqno is
35 // set by a CSS class applied in buildTree.js. That would have worked
36 // in MathML if browsers supported <mlabeledtr>. Since they don't, we
37 // need to rewrite the way this function is called.
38 },
39});
40