1 |
|
2 |
|
3 |
|
4 | import defineFunction from "../defineFunction";
|
5 | import buildCommon from "../buildCommon";
|
6 | import mathMLTree from "../mathMLTree";
|
7 | import {calculateSize} from "../units";
|
8 | import {assertNodeType} from "../parseNode";
|
9 |
|
10 |
|
11 |
|
12 | defineFunction({
|
13 | type: "kern",
|
14 | names: ["\\kern", "\\mkern", "\\hskip", "\\mskip"],
|
15 | props: {
|
16 | numArgs: 1,
|
17 | argTypes: ["size"],
|
18 | allowedInText: true,
|
19 | },
|
20 | handler({parser, funcName}, args) {
|
21 | const size = assertNodeType(args[0], "size");
|
22 | if (parser.settings.strict) {
|
23 | const mathFunction = (funcName[1] === 'm');
|
24 | const muUnit = (size.value.unit === 'mu');
|
25 | if (mathFunction) {
|
26 | if (!muUnit) {
|
27 | parser.settings.reportNonstrict("mathVsTextUnits",
|
28 | `LaTeX's ${funcName} supports only mu units, ` +
|
29 | `not ${size.value.unit} units`);
|
30 | }
|
31 | if (parser.mode !== "math") {
|
32 | parser.settings.reportNonstrict("mathVsTextUnits",
|
33 | `LaTeX's ${funcName} works only in math mode`);
|
34 | }
|
35 | } else {
|
36 | if (muUnit) {
|
37 | parser.settings.reportNonstrict("mathVsTextUnits",
|
38 | `LaTeX's ${funcName} doesn't support mu units`);
|
39 | }
|
40 | }
|
41 | }
|
42 | return {
|
43 | type: "kern",
|
44 | mode: parser.mode,
|
45 | dimension: size.value,
|
46 | };
|
47 | },
|
48 | htmlBuilder(group, options) {
|
49 | return buildCommon.makeGlue(group.dimension, options);
|
50 | },
|
51 | mathmlBuilder(group, options) {
|
52 | const dimension = calculateSize(group.dimension, options);
|
53 | return new mathMLTree.SpaceNode(dimension);
|
54 | },
|
55 | });
|