katex 0.16.46 → 0.17.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +5 -10
- package/contrib/copy-tex/README.md +2 -2
- package/contrib/mathtex-script-type/README.md +5 -5
- package/contrib/mhchem/README.md +1 -1
- package/contrib/render-a11y-string/render-a11y-string.ts +1 -1
- package/dist/README.md +5 -10
- package/dist/katex-swap.css +1 -1
- package/dist/katex-swap.min.css +1 -1
- package/dist/katex.css +1 -1
- package/dist/katex.js +255 -434
- package/dist/katex.min.css +1 -1
- package/dist/katex.min.js +1 -1
- package/dist/katex.mjs +243 -415
- package/katex.ts +1 -1
- package/package.json +1 -2
- package/src/MacroExpander.ts +1 -1
- package/src/Namespace.ts +1 -1
- package/src/ParseError.ts +1 -1
- package/src/Parser.ts +42 -48
- package/src/Settings.ts +1 -1
- package/src/SourceLocation.ts +2 -2
- package/src/buildCommon.ts +6 -6
- package/src/buildHTML.ts +4 -5
- package/src/buildMathML.ts +1 -1
- package/src/buildTree.ts +1 -1
- package/src/defineEnvironment.ts +1 -2
- package/src/defineFunction.ts +104 -112
- package/src/environments/array.ts +8 -12
- package/src/environments/cd.ts +8 -8
- package/src/functions/accent.ts +10 -13
- package/src/functions/accentunder.ts +4 -4
- package/src/functions/arrow.ts +5 -5
- package/src/functions/char.ts +3 -4
- package/src/functions/color.ts +10 -13
- package/src/functions/cr.ts +3 -5
- package/src/functions/def.ts +15 -19
- package/src/functions/delimsizing.ts +23 -23
- package/src/functions/enclose.ts +22 -33
- package/src/functions/environment.ts +4 -5
- package/src/functions/font.ts +15 -27
- package/src/functions/genfrac.ts +19 -23
- package/src/functions/hbox.ts +6 -6
- package/src/functions/horizBrace.ts +4 -4
- package/src/functions/href.ts +10 -11
- package/src/functions/html.ts +5 -5
- package/src/functions/htmlmathml.ts +5 -5
- package/src/functions/includegraphics.ts +7 -7
- package/src/functions/kern.ts +6 -6
- package/src/functions/lap.ts +4 -4
- package/src/functions/math.ts +8 -10
- package/src/functions/mathchoice.ts +5 -5
- package/src/functions/mclass.ts +16 -28
- package/src/functions/op.ts +16 -30
- package/src/functions/operatorname.ts +4 -4
- package/src/functions/overline.ts +3 -3
- package/src/functions/phantom.ts +8 -8
- package/src/functions/pmb.ts +5 -5
- package/src/functions/raisebox.ts +5 -5
- package/src/functions/relax.ts +4 -5
- package/src/functions/rule.ts +7 -7
- package/src/functions/sizing.ts +6 -6
- package/src/functions/smash.ts +5 -5
- package/src/functions/sqrt.ts +4 -4
- package/src/functions/styling.ts +5 -5
- package/src/functions/supsub.ts +1 -1
- package/src/functions/symbolsOrd.ts +3 -3
- package/src/functions/symbolsSpacing.ts +1 -1
- package/src/functions/text.ts +7 -7
- package/src/functions/underline.ts +4 -4
- package/src/functions/utils/assembleSupSub.ts +1 -1
- package/src/functions/vcenter.ts +5 -5
- package/src/functions/verb.ts +5 -5
- package/src/parseNode.ts +2 -476
- package/src/parseTree.ts +1 -6
- package/src/spacingData.ts +2 -1
- package/src/stretchy.ts +1 -1
- package/src/svgGeometry.ts +2 -2
- package/src/types/index.ts +12 -0
- package/src/types/nodes.ts +456 -0
- package/src/units.ts +1 -2
- package/src/utils.ts +1 -1
package/katex.ts
CHANGED
|
@@ -23,7 +23,7 @@ import {
|
|
|
23
23
|
} from "./src/domTree";
|
|
24
24
|
|
|
25
25
|
import type {SettingsOptions} from "./src/Settings";
|
|
26
|
-
import type {AnyParseNode} from "./src/
|
|
26
|
+
import type {AnyParseNode} from "./src/types/nodes";
|
|
27
27
|
import type {DomSpan} from "./src/domTree";
|
|
28
28
|
|
|
29
29
|
import {defineSymbol} from './src/symbols';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "katex",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.17.0",
|
|
4
4
|
"description": "Fast math typesetting for the web.",
|
|
5
5
|
"main": "dist/katex.js",
|
|
6
6
|
"types": "types/katex.d.ts",
|
|
@@ -83,7 +83,6 @@
|
|
|
83
83
|
"babel-plugin-version-inline": "^1.0.0",
|
|
84
84
|
"benchmark": "^2.1.4",
|
|
85
85
|
"browserslist": "^4.21.3",
|
|
86
|
-
"browserstack-local": "^1.5.1",
|
|
87
86
|
"caniuse-lite": "^1.0.30001384",
|
|
88
87
|
"css-loader": "^6.7.1",
|
|
89
88
|
"cssnano": "^5.1.13",
|
package/src/MacroExpander.ts
CHANGED
|
@@ -119,7 +119,7 @@ export default class MacroExpander implements MacroContextInterface {
|
|
|
119
119
|
* Find an macro argument without expanding tokens and append the array of
|
|
120
120
|
* tokens to the token stack. Uses Token as a container for the result.
|
|
121
121
|
*/
|
|
122
|
-
scanArgument(isOptional: boolean): Token | null
|
|
122
|
+
scanArgument(isOptional: boolean): Token | null {
|
|
123
123
|
let start;
|
|
124
124
|
let end;
|
|
125
125
|
let tokens;
|
package/src/Namespace.ts
CHANGED
|
@@ -82,7 +82,7 @@ export default class Namespace<Value> {
|
|
|
82
82
|
* to `false` in JavaScript. Use `if (namespace.get(...) != null)` or
|
|
83
83
|
* `if (namespace.has(...))`.
|
|
84
84
|
*/
|
|
85
|
-
get(name: string): Value |
|
|
85
|
+
get(name: string): Value | undefined {
|
|
86
86
|
if (this.current.hasOwnProperty(name)) {
|
|
87
87
|
return this.current[name];
|
|
88
88
|
} else {
|
package/src/ParseError.ts
CHANGED
package/src/Parser.ts
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
import functions from "./functions";
|
|
3
3
|
import MacroExpander, {implicitCommands} from "./MacroExpander";
|
|
4
4
|
import symbols, {extraLatin} from "./symbols";
|
|
5
|
+
import type {Group} from "./atoms";
|
|
5
6
|
import {isAtom} from "./atoms";
|
|
6
7
|
import {validUnit} from "./units";
|
|
7
8
|
import {supportedCodepoint} from "./unicodeScripts";
|
|
@@ -9,17 +10,15 @@ import ParseError from "./ParseError";
|
|
|
9
10
|
import {combiningDiacriticalMarksEndRegex} from "./Lexer";
|
|
10
11
|
import Settings from "./Settings";
|
|
11
12
|
import SourceLocation from "./SourceLocation";
|
|
12
|
-
import {
|
|
13
|
+
import {unicodeSubRegEx, uSubsAndSups} from "./unicodeSupOrSub";
|
|
13
14
|
import {Token} from "./Token";
|
|
14
15
|
|
|
15
16
|
// Pre-evaluate both modules as unicodeSymbols require String.normalize()
|
|
16
17
|
import unicodeAccents from /*preval*/ "./unicodeAccents";
|
|
17
18
|
import unicodeSymbols from /*preval*/ "./unicodeSymbols";
|
|
18
19
|
|
|
19
|
-
import type {
|
|
20
|
-
|
|
21
|
-
import type {Group} from "./atoms";
|
|
22
|
-
import type {Mode, ArgType, BreakToken} from "./types";
|
|
20
|
+
import type {ArgType, BreakToken, Mode} from "./types";
|
|
21
|
+
import type {AnyParseNode, NodeType, ParseNode, SymbolParseNode, UnsupportedCmdParseNode} from "./types/nodes";
|
|
23
22
|
import type {FunctionContext, FunctionSpec} from "./defineFunction";
|
|
24
23
|
import type {EnvSpec} from "./defineEnvironment";
|
|
25
24
|
|
|
@@ -336,13 +335,13 @@ export default class Parser {
|
|
|
336
335
|
/**
|
|
337
336
|
* Parses a group with optional super/subscripts.
|
|
338
337
|
*/
|
|
339
|
-
parseAtom(breakOnTokenText?: BreakToken): AnyParseNode | null
|
|
338
|
+
parseAtom(breakOnTokenText?: BreakToken): AnyParseNode | null {
|
|
340
339
|
// The body of an atom is an implicit group, so that things like
|
|
341
340
|
// \left(x\right)^2 work correctly.
|
|
342
341
|
const base = this.parseGroup("atom", breakOnTokenText);
|
|
343
342
|
|
|
344
343
|
// Internal nodes (e.g. \relax) cannot support super/subscripts.
|
|
345
|
-
// Instead we will pick up super/subscripts with blank base next round.
|
|
344
|
+
// Instead, we will pick up super/subscripts with blank base next round.
|
|
346
345
|
if (base?.type === "internal") {
|
|
347
346
|
return base;
|
|
348
347
|
}
|
|
@@ -352,10 +351,8 @@ export default class Parser {
|
|
|
352
351
|
return base;
|
|
353
352
|
}
|
|
354
353
|
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
let superscript: AnyParseNode | null | undefined;
|
|
358
|
-
let subscript: AnyParseNode | null | undefined;
|
|
354
|
+
let superscript: AnyParseNode | undefined;
|
|
355
|
+
let subscript: AnyParseNode | undefined;
|
|
359
356
|
while (true) {
|
|
360
357
|
// Guaranteed in math mode, so eat any spaces first.
|
|
361
358
|
this.consumeSpaces();
|
|
@@ -366,8 +363,7 @@ export default class Parser {
|
|
|
366
363
|
if (lex.text === "\\limits" || lex.text === "\\nolimits") {
|
|
367
364
|
// We got a limit control
|
|
368
365
|
if (base && base.type === "op") {
|
|
369
|
-
|
|
370
|
-
base.limits = limits;
|
|
366
|
+
base.limits = lex.text === "\\limits";
|
|
371
367
|
base.alwaysHandleSupSub = true;
|
|
372
368
|
} else if (base && base.type === "operatorname") {
|
|
373
369
|
if (base.alwaysHandleSupSub) {
|
|
@@ -447,15 +443,12 @@ export default class Parser {
|
|
|
447
443
|
|
|
448
444
|
// Base must be set if superscript or subscript are set per logic above,
|
|
449
445
|
// but need to check here for type check to pass.
|
|
450
|
-
if (superscript
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
sup: superscript,
|
|
457
|
-
sub: subscript,
|
|
458
|
-
};
|
|
446
|
+
if (superscript && subscript) {
|
|
447
|
+
return {type: "supsub", mode: this.mode, base, sup: superscript, sub: subscript};
|
|
448
|
+
} else if (superscript) {
|
|
449
|
+
return {type: "supsub", mode: this.mode, base, sup: superscript};
|
|
450
|
+
} else if (subscript) {
|
|
451
|
+
return {type: "supsub", mode: this.mode, base, sub: subscript};
|
|
459
452
|
} else {
|
|
460
453
|
// Otherwise return the original body
|
|
461
454
|
return base;
|
|
@@ -468,7 +461,7 @@ export default class Parser {
|
|
|
468
461
|
parseFunction(
|
|
469
462
|
breakOnTokenText?: BreakToken,
|
|
470
463
|
name?: string, // For determining its context
|
|
471
|
-
): AnyParseNode | null
|
|
464
|
+
): AnyParseNode | null {
|
|
472
465
|
const token = this.fetch();
|
|
473
466
|
const func = token.text;
|
|
474
467
|
const funcData = functions[func];
|
|
@@ -481,9 +474,11 @@ export default class Parser {
|
|
|
481
474
|
throw new ParseError(
|
|
482
475
|
"Got function '" + func + "' with no arguments" +
|
|
483
476
|
(name ? " as " + name : ""), token);
|
|
477
|
+
// Treat undefined allowedInText as false.
|
|
484
478
|
} else if (this.mode === "text" && !funcData.allowedInText) {
|
|
485
479
|
throw new ParseError(
|
|
486
480
|
"Can't use function '" + func + "' in text mode", token);
|
|
481
|
+
// Treat undefined allowedInMath as true.
|
|
487
482
|
} else if (this.mode === "math" && funcData.allowedInMath === false) {
|
|
488
483
|
throw new ParseError(
|
|
489
484
|
"Can't use function '" + func + "' in math mode", token);
|
|
@@ -499,7 +494,7 @@ export default class Parser {
|
|
|
499
494
|
callFunction(
|
|
500
495
|
name: string,
|
|
501
496
|
args: AnyParseNode[],
|
|
502
|
-
optArgs: (AnyParseNode | null
|
|
497
|
+
optArgs: (AnyParseNode | null)[],
|
|
503
498
|
token?: Token,
|
|
504
499
|
breakOnTokenText?: BreakToken,
|
|
505
500
|
): AnyParseNode {
|
|
@@ -525,19 +520,20 @@ export default class Parser {
|
|
|
525
520
|
funcData: FunctionSpec<NodeType> | EnvSpec<NodeType>,
|
|
526
521
|
): {
|
|
527
522
|
args: AnyParseNode[];
|
|
528
|
-
optArgs: (AnyParseNode | null
|
|
523
|
+
optArgs: (AnyParseNode | null)[];
|
|
529
524
|
} {
|
|
530
|
-
const
|
|
525
|
+
const numOptionalArgs = funcData.numOptionalArgs ?? 0;
|
|
526
|
+
const totalArgs = funcData.numArgs + numOptionalArgs;
|
|
531
527
|
if (totalArgs === 0) {
|
|
532
528
|
return {args: [], optArgs: []};
|
|
533
529
|
}
|
|
534
530
|
|
|
535
531
|
const args: AnyParseNode[] = [];
|
|
536
|
-
const optArgs: (AnyParseNode | null
|
|
532
|
+
const optArgs: (AnyParseNode | null)[] = [];
|
|
537
533
|
|
|
538
534
|
for (let i = 0; i < totalArgs; i++) {
|
|
539
|
-
let argType = funcData.argTypes
|
|
540
|
-
const isOptional = i <
|
|
535
|
+
let argType = funcData.argTypes?.[i];
|
|
536
|
+
const isOptional = i < numOptionalArgs;
|
|
541
537
|
|
|
542
538
|
if (("primitive" in funcData && funcData.primitive && argType == null) ||
|
|
543
539
|
// \sqrt expands into primitive if optional argument doesn't exist
|
|
@@ -547,7 +543,7 @@ export default class Parser {
|
|
|
547
543
|
}
|
|
548
544
|
|
|
549
545
|
const arg = this.parseGroupOfType(`argument to '${func}'`,
|
|
550
|
-
argType
|
|
546
|
+
argType, isOptional);
|
|
551
547
|
if (isOptional) {
|
|
552
548
|
optArgs.push(arg);
|
|
553
549
|
} else if (arg != null) {
|
|
@@ -565,9 +561,9 @@ export default class Parser {
|
|
|
565
561
|
*/
|
|
566
562
|
parseGroupOfType(
|
|
567
563
|
name: string,
|
|
568
|
-
type: ArgType |
|
|
564
|
+
type: ArgType | undefined,
|
|
569
565
|
optional: boolean,
|
|
570
|
-
): AnyParseNode | null
|
|
566
|
+
): AnyParseNode | null {
|
|
571
567
|
switch (type) {
|
|
572
568
|
case "color":
|
|
573
569
|
return this.parseColorGroup(optional);
|
|
@@ -592,7 +588,7 @@ export default class Parser {
|
|
|
592
588
|
} : null;
|
|
593
589
|
}
|
|
594
590
|
case "raw": {
|
|
595
|
-
const token = this.parseStringGroup(
|
|
591
|
+
const token = this.parseStringGroup(optional);
|
|
596
592
|
return token != null ? {
|
|
597
593
|
type: "raw",
|
|
598
594
|
mode: "text",
|
|
@@ -610,7 +606,6 @@ export default class Parser {
|
|
|
610
606
|
return group;
|
|
611
607
|
}
|
|
612
608
|
case "original":
|
|
613
|
-
case null:
|
|
614
609
|
case undefined:
|
|
615
610
|
return this.parseArgumentGroup(optional);
|
|
616
611
|
default:
|
|
@@ -633,9 +628,8 @@ export default class Parser {
|
|
|
633
628
|
* brace-enclosed tokens plus some position information.
|
|
634
629
|
*/
|
|
635
630
|
parseStringGroup(
|
|
636
|
-
modeName: ArgType, // Used to describe the mode in error messages.
|
|
637
631
|
optional: boolean,
|
|
638
|
-
): Token | null
|
|
632
|
+
): Token | null {
|
|
639
633
|
const argToken = this.gullet.scanArgument(optional);
|
|
640
634
|
if (argToken == null) {
|
|
641
635
|
return null;
|
|
@@ -681,8 +675,8 @@ export default class Parser {
|
|
|
681
675
|
/**
|
|
682
676
|
* Parses a color description.
|
|
683
677
|
*/
|
|
684
|
-
parseColorGroup(optional: boolean): ParseNode<"color-token"> | null
|
|
685
|
-
const res = this.parseStringGroup(
|
|
678
|
+
parseColorGroup(optional: boolean): ParseNode<"color-token"> | null {
|
|
679
|
+
const res = this.parseStringGroup(optional);
|
|
686
680
|
if (res == null) {
|
|
687
681
|
return null;
|
|
688
682
|
}
|
|
@@ -710,8 +704,8 @@ export default class Parser {
|
|
|
710
704
|
/**
|
|
711
705
|
* Parses a size specification, consisting of magnitude and unit.
|
|
712
706
|
*/
|
|
713
|
-
parseSizeGroup(optional: boolean): ParseNode<"size"> | null
|
|
714
|
-
let res: Token | null
|
|
707
|
+
parseSizeGroup(optional: boolean): ParseNode<"size"> | null {
|
|
708
|
+
let res: Token | null;
|
|
715
709
|
let isBlank = false;
|
|
716
710
|
// don't expand before parseStringGroup
|
|
717
711
|
this.gullet.consumeSpaces();
|
|
@@ -719,7 +713,7 @@ export default class Parser {
|
|
|
719
713
|
res = this.parseRegexGroup(
|
|
720
714
|
/^[-+]? *(?:$|\d+|\d+\.\d*|\.\d*) *[a-z]{0,2} *$/, "size");
|
|
721
715
|
} else {
|
|
722
|
-
res = this.parseStringGroup(
|
|
716
|
+
res = this.parseStringGroup(optional);
|
|
723
717
|
}
|
|
724
718
|
if (!res) {
|
|
725
719
|
return null;
|
|
@@ -755,10 +749,10 @@ export default class Parser {
|
|
|
755
749
|
* Parses an URL, checking escaped letters and allowed protocols,
|
|
756
750
|
* and setting the catcode of % as an active character (as in \hyperref).
|
|
757
751
|
*/
|
|
758
|
-
parseUrlGroup(optional: boolean): ParseNode<"url"> | null
|
|
752
|
+
parseUrlGroup(optional: boolean): ParseNode<"url"> | null {
|
|
759
753
|
this.gullet.lexer.setCatcode("%", 13); // active character
|
|
760
754
|
this.gullet.lexer.setCatcode("~", 12); // other character
|
|
761
|
-
const res = this.parseStringGroup(
|
|
755
|
+
const res = this.parseStringGroup(optional);
|
|
762
756
|
this.gullet.lexer.setCatcode("%", 14); // comment character
|
|
763
757
|
this.gullet.lexer.setCatcode("~", 13); // active character
|
|
764
758
|
if (res == null) {
|
|
@@ -779,7 +773,7 @@ export default class Parser {
|
|
|
779
773
|
/**
|
|
780
774
|
* Parses an argument with the mode specified.
|
|
781
775
|
*/
|
|
782
|
-
parseArgumentGroup(optional: boolean, mode?: Mode): ParseNode<"ordgroup"> | null
|
|
776
|
+
parseArgumentGroup(optional: boolean, mode?: Mode): ParseNode<"ordgroup"> | null {
|
|
783
777
|
const argToken = this.gullet.scanArgument(optional);
|
|
784
778
|
if (argToken == null) {
|
|
785
779
|
return null;
|
|
@@ -816,11 +810,11 @@ export default class Parser {
|
|
|
816
810
|
parseGroup(
|
|
817
811
|
name: string, // For error reporting.
|
|
818
812
|
breakOnTokenText?: BreakToken,
|
|
819
|
-
): AnyParseNode | null
|
|
813
|
+
): AnyParseNode | null {
|
|
820
814
|
const firstToken = this.fetch();
|
|
821
815
|
const text = firstToken.text;
|
|
822
816
|
|
|
823
|
-
let result
|
|
817
|
+
let result;
|
|
824
818
|
// Try to parse an open brace or \begingroup
|
|
825
819
|
if (text === "{" || text === "\\begingroup") {
|
|
826
820
|
this.consume();
|
|
@@ -842,7 +836,7 @@ export default class Parser {
|
|
|
842
836
|
// https://tex.stackexchange.com/questions/1930/when-should-one-
|
|
843
837
|
// use-begingroup-instead-of-bgroup
|
|
844
838
|
semisimple: text === "\\begingroup" || undefined,
|
|
845
|
-
}
|
|
839
|
+
} as const satisfies ParseNode<"ordgroup">;
|
|
846
840
|
} else {
|
|
847
841
|
// If there exists a function with this name, parse the function.
|
|
848
842
|
// Otherwise, just return a nucleus
|
|
@@ -917,7 +911,7 @@ export default class Parser {
|
|
|
917
911
|
* Parse a single symbol out of the string. Here, we handle single character
|
|
918
912
|
* symbols and special functions like \verb.
|
|
919
913
|
*/
|
|
920
|
-
parseSymbol(): AnyParseNode | null
|
|
914
|
+
parseSymbol(): AnyParseNode | null {
|
|
921
915
|
const nucleus = this.fetch();
|
|
922
916
|
let text = nucleus.text;
|
|
923
917
|
|
package/src/Settings.ts
CHANGED
|
@@ -8,7 +8,7 @@ import {protocolFromUrl} from "./utils";
|
|
|
8
8
|
import ParseError from "./ParseError";
|
|
9
9
|
import {Token} from "./Token";
|
|
10
10
|
|
|
11
|
-
import type {AnyParseNode} from "./
|
|
11
|
+
import type {AnyParseNode} from "./types/nodes";
|
|
12
12
|
import type {MacroMap} from "./defineMacro";
|
|
13
13
|
|
|
14
14
|
export type StrictFunction =
|
package/src/SourceLocation.ts
CHANGED
|
@@ -25,8 +25,8 @@ export default class SourceLocation {
|
|
|
25
25
|
* - Otherwise, returns null.
|
|
26
26
|
*/
|
|
27
27
|
static range(
|
|
28
|
-
first
|
|
29
|
-
second?: {loc?: SourceLocation | null
|
|
28
|
+
first: {loc?: SourceLocation | null},
|
|
29
|
+
second?: {loc?: SourceLocation | null},
|
|
30
30
|
): SourceLocation | null | undefined {
|
|
31
31
|
if (!second) {
|
|
32
32
|
return first && first.loc;
|
package/src/buildCommon.ts
CHANGED
|
@@ -12,11 +12,10 @@ import {calculateSize, makeEm} from "./units";
|
|
|
12
12
|
import {DocumentFragment} from "./tree";
|
|
13
13
|
|
|
14
14
|
import type Options from "./Options";
|
|
15
|
-
import type {
|
|
16
|
-
import type {
|
|
15
|
+
import type {Measurement, Mode} from "./types";
|
|
16
|
+
import type {ParseNode} from "./types/nodes";
|
|
17
17
|
import type {documentFragment as HtmlDocumentFragment} from "./domTree";
|
|
18
18
|
import type {HtmlDomNode, DomSpan, SvgSpan, CssStyle} from "./domTree";
|
|
19
|
-
import type {Measurement} from "./units";
|
|
20
19
|
import type {
|
|
21
20
|
CharacterMetrics,
|
|
22
21
|
FontName,
|
|
@@ -167,11 +166,12 @@ const boldSymbol = function(
|
|
|
167
166
|
/**
|
|
168
167
|
* Makes either a mathord or textord in the correct font and color.
|
|
169
168
|
*/
|
|
170
|
-
export const makeOrd = function
|
|
171
|
-
group: ParseNode<
|
|
169
|
+
export const makeOrd = function(
|
|
170
|
+
group: ParseNode<"spacing"> | ParseNode<"mathord"> | ParseNode<"textord">,
|
|
172
171
|
options: Options,
|
|
173
|
-
type: "mathord" | "textord",
|
|
174
172
|
): HtmlDocumentFragment | SymbolNode {
|
|
173
|
+
// Spacing nodes are rendered as textord.
|
|
174
|
+
const type: "mathord" | "textord" = group.type === "mathord" ? "mathord" : "textord";
|
|
175
175
|
const mode = group.mode;
|
|
176
176
|
const text = group.text;
|
|
177
177
|
const classes = ["mord"];
|
package/src/buildHTML.ts
CHANGED
|
@@ -8,15 +8,16 @@
|
|
|
8
8
|
import ParseError from "./ParseError";
|
|
9
9
|
import Style from "./Style";
|
|
10
10
|
import {makeGlue, makeSpan, tryCombineChars} from "./buildCommon";
|
|
11
|
-
import {
|
|
11
|
+
import type {DomSpan, HtmlDomNode} from "./domTree";
|
|
12
|
+
import {Anchor, Span} from "./domTree";
|
|
12
13
|
import {makeEm} from "./units";
|
|
13
14
|
import {spacings, tightSpacings} from "./spacingData";
|
|
14
15
|
import {_htmlGroupBuilders as groupBuilders} from "./defineFunction";
|
|
15
16
|
import {DocumentFragment} from "./tree";
|
|
16
17
|
|
|
17
18
|
import type Options from "./Options";
|
|
18
|
-
import type {AnyParseNode} from "./
|
|
19
|
-
import type {
|
|
19
|
+
import type {AnyParseNode} from "./types/nodes";
|
|
20
|
+
import type {Side} from "./types";
|
|
20
21
|
|
|
21
22
|
// Binary atoms (first class `mbin`) change into ordinary atoms (`mord`)
|
|
22
23
|
// depending on their surroundings. See TeXbook pg. 442-446, Rules 5 and 6,
|
|
@@ -35,8 +36,6 @@ const styleMap = {
|
|
|
35
36
|
"scriptscript": Style.SCRIPTSCRIPT,
|
|
36
37
|
};
|
|
37
38
|
|
|
38
|
-
type Side = "left" | "right";
|
|
39
|
-
|
|
40
39
|
const DomEnum = {
|
|
41
40
|
mord: "mord",
|
|
42
41
|
mop: "mop",
|
package/src/buildMathML.ts
CHANGED
|
@@ -12,11 +12,11 @@ import {_mathmlGroupBuilders as groupBuilders} from "./defineFunction";
|
|
|
12
12
|
import {MathNode, TextNode} from "./mathMLTree";
|
|
13
13
|
|
|
14
14
|
import type Options from "./Options";
|
|
15
|
-
import type {AnyParseNode, SymbolParseNode} from "./parseNode";
|
|
16
15
|
import type {DomSpan, HtmlDomNode} from "./domTree";
|
|
17
16
|
import type {MathDomNode} from "./mathMLTree";
|
|
18
17
|
import type {Mode} from "./types";
|
|
19
18
|
import type {FontVariant, MathFont} from "./types/fonts";
|
|
19
|
+
import type {AnyParseNode, SymbolParseNode} from "./types/nodes";
|
|
20
20
|
|
|
21
21
|
const noVariantSymbols = new Set(["\\imath", "\\jmath"]);
|
|
22
22
|
const rowLikeTypes = new Set(["mrow", "mtable"]);
|
package/src/buildTree.ts
CHANGED
|
@@ -5,7 +5,7 @@ import Options from "./Options";
|
|
|
5
5
|
import Settings from "./Settings";
|
|
6
6
|
import Style from "./Style";
|
|
7
7
|
|
|
8
|
-
import type {AnyParseNode} from "./
|
|
8
|
+
import type {AnyParseNode} from "./types/nodes";
|
|
9
9
|
import type {DomSpan} from "./domTree";
|
|
10
10
|
|
|
11
11
|
const optionsFromSettings = function(settings: Settings) {
|
package/src/defineEnvironment.ts
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import {_htmlGroupBuilders, _mathmlGroupBuilders} from "./defineFunction";
|
|
2
2
|
|
|
3
3
|
import type Parser from "./Parser";
|
|
4
|
-
import type {AnyParseNode} from "./
|
|
4
|
+
import type {AnyParseNode, NodeType} from "./types/nodes";
|
|
5
5
|
import type {ArgType, Mode} from "./types";
|
|
6
|
-
import type {NodeType} from "./parseNode";
|
|
7
6
|
import type {HtmlBuilder, MathMLBuilder} from "./defineFunction";
|
|
8
7
|
|
|
9
8
|
/**
|