1 |
|
2 | import defineFunction from "../defineFunction";
|
3 | import buildCommon from "../buildCommon";
|
4 | import mathMLTree from "../mathMLTree";
|
5 |
|
6 | import * as html from "../buildHTML";
|
7 | import * as mml from "../buildMathML";
|
8 |
|
9 | defineFunction({
|
10 | type: "underline",
|
11 | names: ["\\underline"],
|
12 | props: {
|
13 | numArgs: 1,
|
14 | allowedInText: true,
|
15 | },
|
16 | handler({parser}, args) {
|
17 | return {
|
18 | type: "underline",
|
19 | mode: parser.mode,
|
20 | body: args[0],
|
21 | };
|
22 | },
|
23 | htmlBuilder(group, options) {
|
24 |
|
25 |
|
26 | const innerGroup = html.buildGroup(group.body, options);
|
27 |
|
28 |
|
29 | const line = buildCommon.makeLineSpan("underline-line", options);
|
30 |
|
31 |
|
32 | const vlist = buildCommon.makeVList({
|
33 | positionType: "top",
|
34 | positionData: innerGroup.height,
|
35 | children: [
|
36 | {type: "kern", size: line.height},
|
37 | {type: "elem", elem: line},
|
38 | {type: "kern", size: 3 * line.height},
|
39 | {type: "elem", elem: innerGroup},
|
40 | ],
|
41 | }, options);
|
42 |
|
43 | return buildCommon.makeSpan(["mord", "underline"], [vlist], options);
|
44 | },
|
45 | mathmlBuilder(group, options) {
|
46 | const operator = new mathMLTree.MathNode(
|
47 | "mo", [new mathMLTree.TextNode("\u203e")]);
|
48 | operator.setAttribute("stretchy", "true");
|
49 |
|
50 | const node = new mathMLTree.MathNode(
|
51 | "munder",
|
52 | [mml.buildGroup(group.body, options), operator]);
|
53 | node.setAttribute("accentunder", "true");
|
54 |
|
55 | return node;
|
56 | },
|
57 | });
|