1 |
|
2 |
|
3 | import defineFunction from "../defineFunction";
|
4 | import buildCommon from "../buildCommon";
|
5 | import mathMLTree from "../mathMLTree";
|
6 | import stretchy from "../stretchy";
|
7 |
|
8 | import * as html from "../buildHTML";
|
9 | import * as mml from "../buildMathML";
|
10 |
|
11 | import type {ParseNode} from "../parseNode";
|
12 |
|
13 | defineFunction({
|
14 | type: "accentUnder",
|
15 | names: [
|
16 | "\\underleftarrow", "\\underrightarrow", "\\underleftrightarrow",
|
17 | "\\undergroup", "\\underlinesegment", "\\utilde",
|
18 | ],
|
19 | props: {
|
20 | numArgs: 1,
|
21 | },
|
22 | handler: ({parser, funcName}, args) => {
|
23 | const base = args[0];
|
24 | return {
|
25 | type: "accentUnder",
|
26 | mode: parser.mode,
|
27 | label: funcName,
|
28 | base: base,
|
29 | };
|
30 | },
|
31 | htmlBuilder: (group: ParseNode<"accentUnder">, options) => {
|
32 |
|
33 | const innerGroup = html.buildGroup(group.base, options);
|
34 |
|
35 | const accentBody = stretchy.svgSpan(group, options);
|
36 | const kern = group.label === "\\utilde" ? 0.12 : 0;
|
37 |
|
38 |
|
39 | const vlist = buildCommon.makeVList({
|
40 | positionType: "bottom",
|
41 | positionData: accentBody.height + kern,
|
42 | children: [
|
43 | {type: "elem", elem: accentBody, wrapperClasses: ["svg-align"]},
|
44 | {type: "kern", size: kern},
|
45 | {type: "elem", elem: innerGroup},
|
46 | ],
|
47 | }, options);
|
48 |
|
49 | return buildCommon.makeSpan(["mord", "accentunder"], [vlist], options);
|
50 | },
|
51 | mathmlBuilder: (group, options) => {
|
52 | const accentNode = stretchy.mathMLnode(group.label);
|
53 | const node = new mathMLTree.MathNode(
|
54 | "munder",
|
55 | [mml.buildGroup(group.base, options), accentNode]
|
56 | );
|
57 | node.setAttribute("accentunder", "true");
|
58 | return node;
|
59 | },
|
60 | });
|