| |
| import defineFunction from "../defineFunction"; |
| import {makeSpan} from "../buildCommon"; |
| import {MathNode} from "../mathMLTree"; |
| import {makeEm} from "../units"; |
|
|
| import * as html from "../buildHTML"; |
| import * as mml from "../buildMathML"; |
|
|
| defineFunction({ |
| type: "lap", |
| names: ["\\mathllap", "\\mathrlap", "\\mathclap"], |
| numArgs: 1, |
| allowedInText: true, |
|
|
| handler: ({parser, funcName}, args) => { |
| const body = args[0]; |
| return { |
| type: "lap", |
| mode: parser.mode, |
| alignment: funcName.slice(5), |
| body, |
| }; |
| }, |
|
|
| htmlBuilder: (group, options) => { |
| |
| let inner; |
| if (group.alignment === "clap") { |
| |
| inner = makeSpan( |
| [], [html.buildGroup(group.body, options)]); |
| |
| inner = makeSpan(["inner"], [inner], options); |
| } else { |
| inner = makeSpan( |
| ["inner"], [html.buildGroup(group.body, options)]); |
| } |
| const fix = makeSpan(["fix"], []); |
| let node = makeSpan( |
| [group.alignment], [inner, fix], options); |
|
|
| |
| |
| |
| |
| |
| const strut = makeSpan(["strut"]); |
| strut.style.height = makeEm(node.height + node.depth); |
| if (node.depth) { |
| strut.style.verticalAlign = makeEm(-node.depth); |
| } |
| node.children.unshift(strut); |
|
|
| |
| |
| node = makeSpan(["thinbox"], [node], options); |
| return makeSpan(["mord", "vbox"], [node], options); |
| }, |
| mathmlBuilder: (group, options) => { |
| |
| const node = new MathNode( |
| "mpadded", [mml.buildGroup(group.body, options)]); |
|
|
| if (group.alignment !== "rlap") { |
| const offset = (group.alignment === "llap" ? "-1" : "-0.5"); |
| node.setAttribute("lspace", offset + "width"); |
| } |
| node.setAttribute("width", "0px"); |
|
|
| return node; |
| }, |
| }); |
|
|