UNPKG

1.21 kBJavaScriptView Raw
1// @flow
2import {defineFunctionBuilders} from "../defineFunction";
3import buildCommon from "../buildCommon";
4import mathMLTree from "../mathMLTree";
5
6import * as mml from "../buildMathML";
7
8// Operator ParseNodes created in Parser.js from symbol Groups in src/symbols.js.
9
10defineFunctionBuilders({
11 type: "atom",
12 htmlBuilder(group, options) {
13 return buildCommon.mathsym(
14 group.text, group.mode, options, ["m" + group.family]);
15 },
16 mathmlBuilder(group, options) {
17 const node = new mathMLTree.MathNode(
18 "mo", [mml.makeText(group.text, group.mode)]);
19 if (group.family === "bin") {
20 const variant = mml.getVariant(group, options);
21 if (variant === "bold-italic") {
22 node.setAttribute("mathvariant", variant);
23 }
24 } else if (group.family === "punct") {
25 node.setAttribute("separator", "true");
26 } else if (group.family === "open" || group.family === "close") {
27 // Delims built here should not stretch vertically.
28 // See delimsizing.js for stretchy delims.
29 node.setAttribute("stretchy", "false");
30 }
31 return node;
32 },
33});
34