katex 0.16.28 → 0.16.30
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 +3 -3
- package/cli.js +3 -1
- package/contrib/auto-render/auto-render.js +5 -5
- package/contrib/auto-render/index.html +3 -2
- 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/dist/README.md +3 -3
- package/dist/contrib/auto-render.js +4 -4
- package/dist/contrib/auto-render.min.js +1 -1
- package/dist/contrib/auto-render.mjs +2 -2
- package/dist/contrib/copy-tex.js +2 -2
- package/dist/contrib/copy-tex.min.js +1 -1
- package/dist/contrib/mathtex-script-type.min.js +1 -1
- package/dist/contrib/mhchem.min.js +1 -1
- package/dist/contrib/render-a11y-string.min.js +1 -1
- package/dist/katex-swap.css +7 -5
- package/dist/katex-swap.min.css +1 -1
- package/dist/katex.css +6 -4
- package/dist/katex.js +460 -555
- package/dist/katex.min.css +1 -1
- package/dist/katex.min.js +1 -1
- package/dist/katex.mjs +415 -508
- package/katex.js +2 -2
- package/package.json +3 -4
- package/src/MacroExpander.js +2 -2
- package/src/Parser.js +4 -3
- package/src/Settings.js +2 -2
- package/src/buildCommon.js +15 -33
- package/src/buildHTML.js +11 -9
- package/src/buildMathML.js +17 -15
- package/src/buildTree.js +5 -5
- package/src/delimiter.js +32 -40
- package/src/domTree.js +17 -17
- package/src/environments/array.js +40 -39
- package/src/environments/cd.js +10 -10
- package/src/functions/accent.js +17 -17
- package/src/functions/accentunder.js +8 -8
- package/src/functions/arrow.js +16 -16
- package/src/functions/color.js +4 -4
- package/src/functions/cr.js +4 -4
- package/src/functions/delimsizing.js +18 -19
- package/src/functions/enclose.js +15 -15
- package/src/functions/font.js +2 -3
- package/src/functions/genfrac.js +25 -20
- package/src/functions/hbox.js +4 -4
- package/src/functions/horizBrace.js +12 -12
- package/src/functions/href.js +2 -2
- package/src/functions/html.js +2 -2
- package/src/functions/htmlmathml.js +3 -2
- package/src/functions/includegraphics.js +2 -2
- package/src/functions/kern.js +4 -4
- package/src/functions/lap.js +11 -11
- package/src/functions/mathchoice.js +2 -2
- package/src/functions/mclass.js +10 -12
- package/src/functions/op.js +20 -20
- package/src/functions/operatorname.js +12 -12
- package/src/functions/ordgroup.js +3 -3
- package/src/functions/overline.js +8 -8
- package/src/functions/phantom.js +14 -14
- package/src/functions/pmb.js +4 -4
- package/src/functions/raisebox.js +4 -4
- package/src/functions/rule.js +5 -5
- package/src/functions/sizing.js +4 -4
- package/src/functions/smash.js +6 -6
- package/src/functions/sqrt.js +12 -12
- package/src/functions/styling.js +2 -2
- package/src/functions/supsub.js +13 -13
- package/src/functions/symbolsOp.js +4 -4
- package/src/functions/symbolsOrd.js +9 -9
- package/src/functions/symbolsSpacing.js +9 -9
- package/src/functions/tag.js +6 -6
- package/src/functions/text.js +2 -2
- package/src/functions/underline.js +8 -8
- package/src/functions/utils/assembleSupSub.js +9 -9
- package/src/functions/vcenter.js +4 -4
- package/src/functions/verb.js +7 -7
- package/src/macros.js +5 -2
- package/src/mathMLTree.js +5 -12
- package/src/stretchy.js +18 -28
- package/src/styles/fonts.scss +5 -3
- package/src/styles/katex-swap.scss +4 -1
- package/src/styles/katex.scss +6 -4
- package/src/utils.js +10 -41
package/katex.js
CHANGED
|
@@ -13,7 +13,7 @@ import Settings, {SETTINGS_SCHEMA} from "./src/Settings";
|
|
|
13
13
|
|
|
14
14
|
import {buildTree, buildHTMLTree} from "./src/buildTree";
|
|
15
15
|
import parseTree from "./src/parseTree";
|
|
16
|
-
import
|
|
16
|
+
import {makeSpan} from "./src/buildCommon";
|
|
17
17
|
import {
|
|
18
18
|
Span,
|
|
19
19
|
Anchor,
|
|
@@ -97,7 +97,7 @@ const renderError = function(
|
|
|
97
97
|
if (options.throwOnError || !(error instanceof ParseError)) {
|
|
98
98
|
throw error;
|
|
99
99
|
}
|
|
100
|
-
const node =
|
|
100
|
+
const node = makeSpan(["katex-error"],
|
|
101
101
|
[new SymbolNode(expression)]);
|
|
102
102
|
node.setAttribute("title", error.toString());
|
|
103
103
|
node.setAttribute("style", `color:${options.errorColor}`);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "katex",
|
|
3
|
-
"version": "0.16.
|
|
3
|
+
"version": "0.16.30",
|
|
4
4
|
"description": "Fast math typesetting for the web.",
|
|
5
5
|
"main": "dist/katex.js",
|
|
6
6
|
"types": "types/katex.d.ts",
|
|
@@ -114,11 +114,10 @@
|
|
|
114
114
|
"postcss-preset-env": "^7.8.0",
|
|
115
115
|
"postcss-scss": "^4.0.9",
|
|
116
116
|
"prettier": "^2.7.1",
|
|
117
|
-
"query-string": "^7.1.1",
|
|
118
117
|
"rimraf": "^3.0.2",
|
|
119
118
|
"rollup": "^2.79.2",
|
|
120
|
-
"sass": "^1.
|
|
121
|
-
"sass-loader": "^
|
|
119
|
+
"sass": "^1.94.2",
|
|
120
|
+
"sass-loader": "^16.0.6",
|
|
122
121
|
"selenium-webdriver": "^4.4.0",
|
|
123
122
|
"semantic-release": "^19.0.5",
|
|
124
123
|
"sri-toolbox": "^0.2.0",
|
package/src/MacroExpander.js
CHANGED
|
@@ -424,9 +424,9 @@ export default class MacroExpander implements MacroContextInterface {
|
|
|
424
424
|
typeof definition === "function" ? definition(this) : definition;
|
|
425
425
|
if (typeof expansion === "string") {
|
|
426
426
|
let numArgs = 0;
|
|
427
|
-
if (expansion.
|
|
427
|
+
if (expansion.includes("#")) {
|
|
428
428
|
const stripped = expansion.replace(/##/g, "");
|
|
429
|
-
while (stripped.
|
|
429
|
+
while (stripped.includes("#" + (numArgs + 1))) {
|
|
430
430
|
++numArgs;
|
|
431
431
|
}
|
|
432
432
|
}
|
package/src/Parser.js
CHANGED
|
@@ -172,7 +172,8 @@ export default class Parser {
|
|
|
172
172
|
return parse;
|
|
173
173
|
}
|
|
174
174
|
|
|
175
|
-
static endOfExpression: string
|
|
175
|
+
static endOfExpression: Set<string> =
|
|
176
|
+
new Set(["}", "\\endgroup", "\\end", "\\right", "&"]);
|
|
176
177
|
|
|
177
178
|
/**
|
|
178
179
|
* Parses an "expression", which is a list of atoms.
|
|
@@ -198,7 +199,7 @@ export default class Parser {
|
|
|
198
199
|
this.consumeSpaces();
|
|
199
200
|
}
|
|
200
201
|
const lex = this.fetch();
|
|
201
|
-
if (Parser.endOfExpression.
|
|
202
|
+
if (Parser.endOfExpression.has(lex.text)) {
|
|
202
203
|
break;
|
|
203
204
|
}
|
|
204
205
|
if (breakOnTokenText && lex.text === breakOnTokenText) {
|
|
@@ -953,7 +954,7 @@ export default class Parser {
|
|
|
953
954
|
let symbol: AnyParseNode;
|
|
954
955
|
if (symbols[this.mode][text]) {
|
|
955
956
|
if (this.settings.strict && this.mode === 'math' &&
|
|
956
|
-
extraLatin.
|
|
957
|
+
extraLatin.includes(text)) {
|
|
957
958
|
this.settings.reportNonstrict("unicodeTextInMathMode",
|
|
958
959
|
`Latin-1/Unicode text character "${text[0]}" used in ` +
|
|
959
960
|
`math mode`, nucleus);
|
package/src/Settings.js
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* default settings.
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
|
-
import
|
|
8
|
+
import {protocolFromUrl} from "./utils";
|
|
9
9
|
import ParseError from "./ParseError";
|
|
10
10
|
import {Token} from "./Token";
|
|
11
11
|
|
|
@@ -346,7 +346,7 @@ export default class Settings {
|
|
|
346
346
|
*/
|
|
347
347
|
isTrusted(context: AnyTrustContext): boolean {
|
|
348
348
|
if (context.url && !context.protocol) {
|
|
349
|
-
const protocol =
|
|
349
|
+
const protocol = protocolFromUrl(context.url);
|
|
350
350
|
if (protocol == null) {
|
|
351
351
|
return false;
|
|
352
352
|
}
|
package/src/buildCommon.js
CHANGED
|
@@ -50,7 +50,7 @@ const lookupSymbol = function(
|
|
|
50
50
|
* should if present come first in `classes`.
|
|
51
51
|
* TODO(#953): Make `options` mandatory and always pass it in.
|
|
52
52
|
*/
|
|
53
|
-
const makeSymbol = function(
|
|
53
|
+
export const makeSymbol = function(
|
|
54
54
|
value: string,
|
|
55
55
|
fontName: string,
|
|
56
56
|
mode: Mode,
|
|
@@ -95,7 +95,7 @@ const makeSymbol = function(
|
|
|
95
95
|
* Makes a symbol in Main-Regular or AMS-Regular.
|
|
96
96
|
* Used for rel, bin, open, close, inner, and punct.
|
|
97
97
|
*/
|
|
98
|
-
const mathsym = function(
|
|
98
|
+
export const mathsym = function(
|
|
99
99
|
value: string,
|
|
100
100
|
mode: Mode,
|
|
101
101
|
options: Options,
|
|
@@ -152,7 +152,7 @@ const boldsymbol = function(
|
|
|
152
152
|
/**
|
|
153
153
|
* Makes either a mathord or textord in the correct font and color.
|
|
154
154
|
*/
|
|
155
|
-
const makeOrd = function<NODETYPE: "spacing" | "mathord" | "textord">(
|
|
155
|
+
export const makeOrd = function<NODETYPE: "spacing" | "mathord" | "textord">(
|
|
156
156
|
group: ParseNode<NODETYPE>,
|
|
157
157
|
options: Options,
|
|
158
158
|
type: "mathord" | "textord",
|
|
@@ -277,7 +277,7 @@ const canCombine = (prev: SymbolNode, next: SymbolNode) => {
|
|
|
277
277
|
* Combine consecutive domTree.symbolNodes into a single symbolNode.
|
|
278
278
|
* Note: this function mutates the argument.
|
|
279
279
|
*/
|
|
280
|
-
const tryCombineChars = (chars: HtmlDomNode[]): HtmlDomNode[] => {
|
|
280
|
+
export const tryCombineChars = (chars: HtmlDomNode[]): HtmlDomNode[] => {
|
|
281
281
|
for (let i = 0; i < chars.length - 1; i++) {
|
|
282
282
|
const prev = chars[i];
|
|
283
283
|
const next = chars[i + 1];
|
|
@@ -336,7 +336,7 @@ const sizeElementFromChildren = function(
|
|
|
336
336
|
* TODO: add a separate argument for math class (e.g. `mop`, `mbin`), which
|
|
337
337
|
* should if present come first in `classes`.
|
|
338
338
|
*/
|
|
339
|
-
const makeSpan = function(
|
|
339
|
+
export const makeSpan = function(
|
|
340
340
|
classes?: string[],
|
|
341
341
|
children?: HtmlDomNode[],
|
|
342
342
|
options?: Options,
|
|
@@ -351,14 +351,14 @@ const makeSpan = function(
|
|
|
351
351
|
|
|
352
352
|
// SVG one is simpler -- doesn't require height, depth, max-font setting.
|
|
353
353
|
// This is also a separate method for typesafety.
|
|
354
|
-
const makeSvgSpan = (
|
|
354
|
+
export const makeSvgSpan = (
|
|
355
355
|
classes?: string[],
|
|
356
356
|
children?: SvgNode[],
|
|
357
357
|
options?: Options,
|
|
358
358
|
style?: CssStyle,
|
|
359
359
|
): SvgSpan => new Span(classes, children, options, style);
|
|
360
360
|
|
|
361
|
-
const makeLineSpan = function(
|
|
361
|
+
export const makeLineSpan = function(
|
|
362
362
|
className: string,
|
|
363
363
|
options: Options,
|
|
364
364
|
thickness?: number,
|
|
@@ -377,7 +377,7 @@ const makeLineSpan = function(
|
|
|
377
377
|
* Makes an anchor with the given href, list of classes, list of children,
|
|
378
378
|
* and options.
|
|
379
379
|
*/
|
|
380
|
-
const makeAnchor = function(
|
|
380
|
+
export const makeAnchor = function(
|
|
381
381
|
href: string,
|
|
382
382
|
classes: string[],
|
|
383
383
|
children: HtmlDomNode[],
|
|
@@ -393,7 +393,7 @@ const makeAnchor = function(
|
|
|
393
393
|
/**
|
|
394
394
|
* Makes a document fragment with the given list of children.
|
|
395
395
|
*/
|
|
396
|
-
const makeFragment = function(
|
|
396
|
+
export const makeFragment = function(
|
|
397
397
|
children: HtmlDomNode[],
|
|
398
398
|
): HtmlDocumentFragment {
|
|
399
399
|
const fragment = new DocumentFragment(children);
|
|
@@ -407,7 +407,7 @@ const makeFragment = function(
|
|
|
407
407
|
* Wraps group in a span if it's a document fragment, allowing to apply classes
|
|
408
408
|
* and styles
|
|
409
409
|
*/
|
|
410
|
-
const wrapFragment = function(
|
|
410
|
+
export const wrapFragment = function(
|
|
411
411
|
group: HtmlDomNode,
|
|
412
412
|
options: Options,
|
|
413
413
|
): HtmlDomNode {
|
|
@@ -534,7 +534,7 @@ const getVListChildrenAndDepth = function(params: VListParam): {
|
|
|
534
534
|
*
|
|
535
535
|
* See VListParam documentation above.
|
|
536
536
|
*/
|
|
537
|
-
const makeVList = function(params: VListParam, options: Options): DomSpan {
|
|
537
|
+
export const makeVList = function(params: VListParam, options: Options): DomSpan {
|
|
538
538
|
const {children, depth} = getVListChildrenAndDepth(params);
|
|
539
539
|
|
|
540
540
|
// Create a strut that is taller than any list item. The strut is added to
|
|
@@ -626,7 +626,7 @@ const makeVList = function(params: VListParam, options: Options): DomSpan {
|
|
|
626
626
|
// Glue is a concept from TeX which is a flexible space between elements in
|
|
627
627
|
// either a vertical or horizontal list. In KaTeX, at least for now, it's
|
|
628
628
|
// static space between elements in a horizontal layout.
|
|
629
|
-
const makeGlue = (measurement: Measurement, options: Options): DomSpan => {
|
|
629
|
+
export const makeGlue = (measurement: Measurement, options: Options): DomSpan => {
|
|
630
630
|
// Make an empty span for the space
|
|
631
631
|
const rule = makeSpan(["mspace"], [], options);
|
|
632
632
|
const size = calculateSize(measurement, options);
|
|
@@ -678,7 +678,7 @@ const retrieveTextFontName = function(
|
|
|
678
678
|
* - fontName: the "style" parameter to fontMetrics.getCharacterMetrics
|
|
679
679
|
*/
|
|
680
680
|
// A map between tex font commands an MathML mathvariant attribute values
|
|
681
|
-
const fontMap: {[string]: {| variant: FontVariant, fontName: string |}} = {
|
|
681
|
+
export const fontMap: {[string]: {| variant: FontVariant, fontName: string |}} = {
|
|
682
682
|
// styles
|
|
683
683
|
"mathbf": {
|
|
684
684
|
variant: "bold",
|
|
@@ -735,7 +735,7 @@ const fontMap: {[string]: {| variant: FontVariant, fontName: string |}} = {
|
|
|
735
735
|
},
|
|
736
736
|
};
|
|
737
737
|
|
|
738
|
-
const svgData: {
|
|
738
|
+
export const svgData: {
|
|
739
739
|
[string]: ([string, number, number])
|
|
740
740
|
} = {
|
|
741
741
|
// path, width, height
|
|
@@ -746,7 +746,7 @@ const svgData: {
|
|
|
746
746
|
oiiintSize2: ["oiiintSize2", 1.98, 0.659],
|
|
747
747
|
};
|
|
748
748
|
|
|
749
|
-
const staticSvg = function(value: string, options: Options): SvgSpan {
|
|
749
|
+
export const staticSvg = function(value: string, options: Options): SvgSpan {
|
|
750
750
|
// Create a span with inline SVG for the element.
|
|
751
751
|
const [pathName, width, height] = svgData[value];
|
|
752
752
|
const path = new PathNode(pathName);
|
|
@@ -764,21 +764,3 @@ const staticSvg = function(value: string, options: Options): SvgSpan {
|
|
|
764
764
|
span.style.width = makeEm(width);
|
|
765
765
|
return span;
|
|
766
766
|
};
|
|
767
|
-
|
|
768
|
-
export default {
|
|
769
|
-
fontMap,
|
|
770
|
-
makeSymbol,
|
|
771
|
-
mathsym,
|
|
772
|
-
makeSpan,
|
|
773
|
-
makeSvgSpan,
|
|
774
|
-
makeLineSpan,
|
|
775
|
-
makeAnchor,
|
|
776
|
-
makeFragment,
|
|
777
|
-
wrapFragment,
|
|
778
|
-
makeVList,
|
|
779
|
-
makeOrd,
|
|
780
|
-
makeGlue,
|
|
781
|
-
staticSvg,
|
|
782
|
-
svgData,
|
|
783
|
-
tryCombineChars,
|
|
784
|
-
};
|
package/src/buildHTML.js
CHANGED
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
|
|
9
9
|
import ParseError from "./ParseError";
|
|
10
10
|
import Style from "./Style";
|
|
11
|
-
import
|
|
11
|
+
import {makeGlue, makeSpan, tryCombineChars} from "./buildCommon";
|
|
12
12
|
import {Span, Anchor} from "./domTree";
|
|
13
13
|
import {makeEm} from "./units";
|
|
14
14
|
import {spacings, tightSpacings} from "./spacingData";
|
|
@@ -19,13 +19,15 @@ import type Options from "./Options";
|
|
|
19
19
|
import type {AnyParseNode} from "./parseNode";
|
|
20
20
|
import type {HtmlDomNode, DomSpan} from "./domTree";
|
|
21
21
|
|
|
22
|
-
const makeSpan = buildCommon.makeSpan;
|
|
23
|
-
|
|
24
22
|
// Binary atoms (first class `mbin`) change into ordinary atoms (`mord`)
|
|
25
23
|
// depending on their surroundings. See TeXbook pg. 442-446, Rules 5 and 6,
|
|
26
24
|
// and the text before Rule 19.
|
|
27
|
-
const binLeftCanceller = [
|
|
28
|
-
|
|
25
|
+
const binLeftCanceller = new Set([
|
|
26
|
+
"leftmost", "mbin", "mopen", "mrel", "mop", "mpunct",
|
|
27
|
+
]);
|
|
28
|
+
const binRightCanceller = new Set([
|
|
29
|
+
"rightmost", "mrel", "mclose", "mpunct",
|
|
30
|
+
]);
|
|
29
31
|
|
|
30
32
|
const styleMap = {
|
|
31
33
|
"display": Style.DISPLAY,
|
|
@@ -75,7 +77,7 @@ export const buildExpression = function(
|
|
|
75
77
|
}
|
|
76
78
|
|
|
77
79
|
// Combine consecutive domTree.symbolNodes into a single symbolNode.
|
|
78
|
-
|
|
80
|
+
tryCombineChars(groups);
|
|
79
81
|
|
|
80
82
|
// If `expression` is a partial group, let the parent handle spacings
|
|
81
83
|
// to avoid processing groups multiple times.
|
|
@@ -109,9 +111,9 @@ export const buildExpression = function(
|
|
|
109
111
|
traverseNonSpaceNodes(groups, (node, prev) => {
|
|
110
112
|
const prevType = prev.classes[0];
|
|
111
113
|
const type = node.classes[0];
|
|
112
|
-
if (prevType === "mbin" && binRightCanceller.
|
|
114
|
+
if (prevType === "mbin" && binRightCanceller.has(type)) {
|
|
113
115
|
prev.classes[0] = "mord";
|
|
114
|
-
} else if (type === "mbin" && binLeftCanceller.
|
|
116
|
+
} else if (type === "mbin" && binLeftCanceller.has(prevType)) {
|
|
115
117
|
node.classes[0] = "mord";
|
|
116
118
|
}
|
|
117
119
|
}, {node: dummyPrev}, dummyNext, isRoot);
|
|
@@ -125,7 +127,7 @@ export const buildExpression = function(
|
|
|
125
127
|
? tightSpacings[prevType][type]
|
|
126
128
|
: spacings[prevType][type]) : null;
|
|
127
129
|
if (space) { // Insert glue (spacing) after the `prev`.
|
|
128
|
-
return
|
|
130
|
+
return makeGlue(space, glueOptions);
|
|
129
131
|
}
|
|
130
132
|
}, {node: dummyPrev}, dummyNext, isRoot);
|
|
131
133
|
|
package/src/buildMathML.js
CHANGED
|
@@ -5,9 +5,8 @@
|
|
|
5
5
|
* parser.
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
|
-
import
|
|
8
|
+
import {fontMap, makeSpan} from "./buildCommon";
|
|
9
9
|
import {getCharacterMetrics} from "./fontMetrics";
|
|
10
|
-
import mathMLTree from "./mathMLTree";
|
|
11
10
|
import ParseError from "./ParseError";
|
|
12
11
|
import symbols, {ligatures} from "./symbols";
|
|
13
12
|
import {_mathmlGroupBuilders as groupBuilders} from "./defineFunction";
|
|
@@ -19,6 +18,9 @@ import type {DomSpan} from "./domTree";
|
|
|
19
18
|
import type {MathDomNode} from "./mathMLTree";
|
|
20
19
|
import type {FontVariant, Mode} from "./types";
|
|
21
20
|
|
|
21
|
+
const noVariantSymbols = new Set(["\\imath", "\\jmath"]);
|
|
22
|
+
const rowLikeTypes = new Set(["mrow", "mtable"]);
|
|
23
|
+
|
|
22
24
|
/**
|
|
23
25
|
* Takes a symbol and converts it into a MathML text node after performing
|
|
24
26
|
* optional replacement from symbols.js.
|
|
@@ -36,7 +38,7 @@ export const makeText = function(
|
|
|
36
38
|
text = symbols[mode][text].replace;
|
|
37
39
|
}
|
|
38
40
|
|
|
39
|
-
return new
|
|
41
|
+
return new TextNode(text);
|
|
40
42
|
};
|
|
41
43
|
|
|
42
44
|
/**
|
|
@@ -47,7 +49,7 @@ export const makeRow = function(body: $ReadOnlyArray<MathDomNode>): MathDomNode
|
|
|
47
49
|
if (body.length === 1) {
|
|
48
50
|
return body[0];
|
|
49
51
|
} else {
|
|
50
|
-
return new
|
|
52
|
+
return new MathNode("mrow", body);
|
|
51
53
|
}
|
|
52
54
|
};
|
|
53
55
|
|
|
@@ -111,7 +113,7 @@ export const getVariant = function(
|
|
|
111
113
|
}
|
|
112
114
|
|
|
113
115
|
let text = group.text;
|
|
114
|
-
if (
|
|
116
|
+
if (noVariantSymbols.has(text)) {
|
|
115
117
|
return null;
|
|
116
118
|
}
|
|
117
119
|
|
|
@@ -119,9 +121,9 @@ export const getVariant = function(
|
|
|
119
121
|
text = symbols[mode][text].replace;
|
|
120
122
|
}
|
|
121
123
|
|
|
122
|
-
const fontName =
|
|
124
|
+
const fontName = fontMap[font].fontName;
|
|
123
125
|
if (getCharacterMetrics(text, fontName, mode)) {
|
|
124
|
-
return
|
|
126
|
+
return fontMap[font].variant;
|
|
125
127
|
}
|
|
126
128
|
|
|
127
129
|
return null;
|
|
@@ -249,7 +251,7 @@ export const buildGroup = function(
|
|
|
249
251
|
options: Options,
|
|
250
252
|
): MathNode {
|
|
251
253
|
if (!group) {
|
|
252
|
-
return new
|
|
254
|
+
return new MathNode("mrow");
|
|
253
255
|
}
|
|
254
256
|
|
|
255
257
|
if (groupBuilders[group.type]) {
|
|
@@ -290,22 +292,22 @@ export default function buildMathML(
|
|
|
290
292
|
// tag correctly, unless it's a single <mrow> or <mtable>.
|
|
291
293
|
let wrapper;
|
|
292
294
|
if (expression.length === 1 && expression[0] instanceof MathNode &&
|
|
293
|
-
|
|
295
|
+
rowLikeTypes.has(expression[0].type)) {
|
|
294
296
|
wrapper = expression[0];
|
|
295
297
|
} else {
|
|
296
|
-
wrapper = new
|
|
298
|
+
wrapper = new MathNode("mrow", expression);
|
|
297
299
|
}
|
|
298
300
|
|
|
299
301
|
// Build a TeX annotation of the source
|
|
300
|
-
const annotation = new
|
|
301
|
-
"annotation", [new
|
|
302
|
+
const annotation = new MathNode(
|
|
303
|
+
"annotation", [new TextNode(texExpression)]);
|
|
302
304
|
|
|
303
305
|
annotation.setAttribute("encoding", "application/x-tex");
|
|
304
306
|
|
|
305
|
-
const semantics = new
|
|
307
|
+
const semantics = new MathNode(
|
|
306
308
|
"semantics", [wrapper, annotation]);
|
|
307
309
|
|
|
308
|
-
const math = new
|
|
310
|
+
const math = new MathNode("math", [semantics]);
|
|
309
311
|
math.setAttribute("xmlns", "http://www.w3.org/1998/Math/MathML");
|
|
310
312
|
if (isDisplayMode) {
|
|
311
313
|
math.setAttribute("display", "block");
|
|
@@ -317,5 +319,5 @@ export default function buildMathML(
|
|
|
317
319
|
// of span are expected to have more fields in `buildHtml` contexts.
|
|
318
320
|
const wrapperClass = forMathmlOnly ? "katex" : "katex-mathml";
|
|
319
321
|
// $FlowFixMe
|
|
320
|
-
return
|
|
322
|
+
return makeSpan([wrapperClass], [math]);
|
|
321
323
|
}
|
package/src/buildTree.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// @flow
|
|
2
2
|
import buildHTML from "./buildHTML";
|
|
3
3
|
import buildMathML from "./buildMathML";
|
|
4
|
-
import
|
|
4
|
+
import {makeSpan} from "./buildCommon";
|
|
5
5
|
import Options from "./Options";
|
|
6
6
|
import Settings from "./Settings";
|
|
7
7
|
import Style from "./Style";
|
|
@@ -26,7 +26,7 @@ const displayWrap = function(node: DomSpan, settings: Settings): DomSpan {
|
|
|
26
26
|
if (settings.fleqn) {
|
|
27
27
|
classes.push("fleqn");
|
|
28
28
|
}
|
|
29
|
-
node =
|
|
29
|
+
node = makeSpan(classes, [node]);
|
|
30
30
|
}
|
|
31
31
|
return node;
|
|
32
32
|
};
|
|
@@ -42,12 +42,12 @@ export const buildTree = function(
|
|
|
42
42
|
return buildMathML(tree, expression, options, settings.displayMode, true);
|
|
43
43
|
} else if (settings.output === "html") {
|
|
44
44
|
const htmlNode = buildHTML(tree, options);
|
|
45
|
-
katexNode =
|
|
45
|
+
katexNode = makeSpan(["katex"], [htmlNode]);
|
|
46
46
|
} else {
|
|
47
47
|
const mathMLNode = buildMathML(tree, expression, options,
|
|
48
48
|
settings.displayMode, false);
|
|
49
49
|
const htmlNode = buildHTML(tree, options);
|
|
50
|
-
katexNode =
|
|
50
|
+
katexNode = makeSpan(["katex"], [mathMLNode, htmlNode]);
|
|
51
51
|
}
|
|
52
52
|
|
|
53
53
|
return displayWrap(katexNode, settings);
|
|
@@ -60,7 +60,7 @@ export const buildHTMLTree = function(
|
|
|
60
60
|
): DomSpan {
|
|
61
61
|
const options = optionsFromSettings(settings);
|
|
62
62
|
const htmlNode = buildHTML(tree, options);
|
|
63
|
-
const katexNode =
|
|
63
|
+
const katexNode = makeSpan(["katex"], [htmlNode]);
|
|
64
64
|
return displayWrap(katexNode, settings);
|
|
65
65
|
};
|
|
66
66
|
|