katex 0.16.37 → 0.16.39
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 +4 -4
- 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 +4 -4
- 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 +82 -72
- package/dist/katex.min.css +1 -1
- package/dist/katex.min.js +1 -1
- package/dist/katex.mjs +72 -64
- package/package.json +1 -1
- package/src/domTree.ts +13 -0
- package/src/functions/accent.ts +15 -13
- package/src/macros.ts +0 -5
- package/src/symbols.ts +4 -0
package/dist/katex.mjs
CHANGED
|
@@ -754,6 +754,54 @@ var tallDelim = function tallDelim(label, midHeight) {
|
|
|
754
754
|
}
|
|
755
755
|
};
|
|
756
756
|
|
|
757
|
+
/**
|
|
758
|
+
* This node represents a document fragment, which contains elements, but when
|
|
759
|
+
* placed into the DOM doesn't have any representation itself. It only contains
|
|
760
|
+
* children and doesn't have any DOM node properties.
|
|
761
|
+
*/
|
|
762
|
+
class DocumentFragment {
|
|
763
|
+
// Never used; needed for satisfying interface.
|
|
764
|
+
constructor(children) {
|
|
765
|
+
this.children = children;
|
|
766
|
+
this.classes = [];
|
|
767
|
+
this.height = 0;
|
|
768
|
+
this.depth = 0;
|
|
769
|
+
this.maxFontSize = 0;
|
|
770
|
+
this.style = {};
|
|
771
|
+
}
|
|
772
|
+
hasClass(className) {
|
|
773
|
+
return this.classes.includes(className);
|
|
774
|
+
}
|
|
775
|
+
/** Convert the fragment into a node. */
|
|
776
|
+
toNode() {
|
|
777
|
+
var frag = document.createDocumentFragment();
|
|
778
|
+
for (var i = 0; i < this.children.length; i++) {
|
|
779
|
+
frag.appendChild(this.children[i].toNode());
|
|
780
|
+
}
|
|
781
|
+
return frag;
|
|
782
|
+
}
|
|
783
|
+
/** Convert the fragment into HTML markup. */
|
|
784
|
+
toMarkup() {
|
|
785
|
+
var markup = "";
|
|
786
|
+
// Simply concatenate the markup for the children together.
|
|
787
|
+
for (var i = 0; i < this.children.length; i++) {
|
|
788
|
+
markup += this.children[i].toMarkup();
|
|
789
|
+
}
|
|
790
|
+
return markup;
|
|
791
|
+
}
|
|
792
|
+
/**
|
|
793
|
+
* Converts the math node into a string, similar to innerText. Applies to
|
|
794
|
+
* MathDomNode's only.
|
|
795
|
+
*/
|
|
796
|
+
toText() {
|
|
797
|
+
// To avoid this, we would subclass documentFragment separately for
|
|
798
|
+
// MathML, but polyfills for subclassing is expensive per PR 1469.
|
|
799
|
+
// TODO(ts): Only works for ChildType = MathDomNode.
|
|
800
|
+
var toText = child => child.toText();
|
|
801
|
+
return this.children.map(toText).join("");
|
|
802
|
+
}
|
|
803
|
+
}
|
|
804
|
+
|
|
757
805
|
/**
|
|
758
806
|
* This file does conversion between units. In particular, it provides
|
|
759
807
|
* calculateSize to convert other units into ems.
|
|
@@ -1250,6 +1298,13 @@ function assertSpan(group) {
|
|
|
1250
1298
|
throw new Error("Expected span<HtmlDomNode> but got " + String(group) + ".");
|
|
1251
1299
|
}
|
|
1252
1300
|
}
|
|
1301
|
+
/**
|
|
1302
|
+
* Whether an HtmlDomNode has HtmlDomNode children.
|
|
1303
|
+
* HtmlDomNode is a base type representing a union of
|
|
1304
|
+
* SymbolNode, SvgSpan, DomSpan, Anchor, and documentFragment.
|
|
1305
|
+
* In the last three cases, the children are HtmlDomNode[].
|
|
1306
|
+
*/
|
|
1307
|
+
var hasHtmlDomChildren = node => node instanceof Span || node instanceof Anchor || node instanceof DocumentFragment;
|
|
1253
1308
|
|
|
1254
1309
|
// This file is GENERATED by buildMetrics.sh. DO NOT MODIFY.
|
|
1255
1310
|
var fontMetricsData = {
|
|
@@ -3693,6 +3748,10 @@ defineSymbol(math, main, rel, "\u220b", "\\owns");
|
|
|
3693
3748
|
// Punctuation
|
|
3694
3749
|
defineSymbol(math, main, punct, "\u002e", "\\ldotp");
|
|
3695
3750
|
defineSymbol(math, main, punct, "\u22c5", "\\cdotp");
|
|
3751
|
+
// The KaTeX fonts do not contain U+00B7. Use the centered dot glyph at U+22C5
|
|
3752
|
+
// in both modes, but keep math-mode punctuation spacing only in math mode.
|
|
3753
|
+
defineSymbol(math, main, punct, "\u22c5", "\u00b7");
|
|
3754
|
+
defineSymbol(text, main, textord, "\u22c5", "\u00b7");
|
|
3696
3755
|
// Misc Symbols
|
|
3697
3756
|
defineSymbol(math, main, textord, "\u0023", "\\#");
|
|
3698
3757
|
defineSymbol(text, main, textord, "\u0023", "\\#");
|
|
@@ -4528,54 +4587,6 @@ var wideCharacterFont = (wideChar, mode) => {
|
|
|
4528
4587
|
}
|
|
4529
4588
|
};
|
|
4530
4589
|
|
|
4531
|
-
/**
|
|
4532
|
-
* This node represents a document fragment, which contains elements, but when
|
|
4533
|
-
* placed into the DOM doesn't have any representation itself. It only contains
|
|
4534
|
-
* children and doesn't have any DOM node properties.
|
|
4535
|
-
*/
|
|
4536
|
-
class DocumentFragment {
|
|
4537
|
-
// Never used; needed for satisfying interface.
|
|
4538
|
-
constructor(children) {
|
|
4539
|
-
this.children = children;
|
|
4540
|
-
this.classes = [];
|
|
4541
|
-
this.height = 0;
|
|
4542
|
-
this.depth = 0;
|
|
4543
|
-
this.maxFontSize = 0;
|
|
4544
|
-
this.style = {};
|
|
4545
|
-
}
|
|
4546
|
-
hasClass(className) {
|
|
4547
|
-
return this.classes.includes(className);
|
|
4548
|
-
}
|
|
4549
|
-
/** Convert the fragment into a node. */
|
|
4550
|
-
toNode() {
|
|
4551
|
-
var frag = document.createDocumentFragment();
|
|
4552
|
-
for (var i = 0; i < this.children.length; i++) {
|
|
4553
|
-
frag.appendChild(this.children[i].toNode());
|
|
4554
|
-
}
|
|
4555
|
-
return frag;
|
|
4556
|
-
}
|
|
4557
|
-
/** Convert the fragment into HTML markup. */
|
|
4558
|
-
toMarkup() {
|
|
4559
|
-
var markup = "";
|
|
4560
|
-
// Simply concatenate the markup for the children together.
|
|
4561
|
-
for (var i = 0; i < this.children.length; i++) {
|
|
4562
|
-
markup += this.children[i].toMarkup();
|
|
4563
|
-
}
|
|
4564
|
-
return markup;
|
|
4565
|
-
}
|
|
4566
|
-
/**
|
|
4567
|
-
* Converts the math node into a string, similar to innerText. Applies to
|
|
4568
|
-
* MathDomNode's only.
|
|
4569
|
-
*/
|
|
4570
|
-
toText() {
|
|
4571
|
-
// To avoid this, we would subclass documentFragment separately for
|
|
4572
|
-
// MathML, but polyfills for subclassing is expensive per PR 1469.
|
|
4573
|
-
// TODO(ts): Only works for ChildType = MathDomNode.
|
|
4574
|
-
var toText = child => child.toText();
|
|
4575
|
-
return this.children.map(toText).join("");
|
|
4576
|
-
}
|
|
4577
|
-
}
|
|
4578
|
-
|
|
4579
4590
|
/* eslint no-console:0 */
|
|
4580
4591
|
/**
|
|
4581
4592
|
* Looks up the given symbol in fontMetrics, after applying any symbol
|
|
@@ -6702,6 +6713,14 @@ function checkSymbolNodeType(node) {
|
|
|
6702
6713
|
return null;
|
|
6703
6714
|
}
|
|
6704
6715
|
|
|
6716
|
+
var getBaseSymbol = group => {
|
|
6717
|
+
if (group instanceof SymbolNode) {
|
|
6718
|
+
return group;
|
|
6719
|
+
}
|
|
6720
|
+
if (hasHtmlDomChildren(group) && group.children.length === 1) {
|
|
6721
|
+
return getBaseSymbol(group.children[0]);
|
|
6722
|
+
}
|
|
6723
|
+
};
|
|
6705
6724
|
// NOTE: Unlike most `htmlBuilder`s, this one handles not only "accent", but
|
|
6706
6725
|
// also "supsub" since an accent can affect super/subscripting.
|
|
6707
6726
|
var htmlBuilder$a = (grp, options) => {
|
|
@@ -6743,17 +6762,10 @@ var htmlBuilder$a = (grp, options) => {
|
|
|
6743
6762
|
// and the skewchar.
|
|
6744
6763
|
var skew = 0;
|
|
6745
6764
|
if (mustShift) {
|
|
6746
|
-
|
|
6747
|
-
//
|
|
6748
|
-
|
|
6749
|
-
|
|
6750
|
-
var baseGroup = buildGroup$1(baseChar, options.havingCrampedStyle());
|
|
6751
|
-
// Finally, we pull the skew off of the symbol.
|
|
6752
|
-
skew = assertSymbolDomNode(baseGroup).skew;
|
|
6753
|
-
// Note that we now throw away baseGroup, because the layers we
|
|
6754
|
-
// removed with getBaseElem might contain things like \color which
|
|
6755
|
-
// we can't get rid of.
|
|
6756
|
-
// TODO(emily): Find a better way to get the skew
|
|
6765
|
+
var _getBaseSymbol$skew, _getBaseSymbol;
|
|
6766
|
+
// Read the skew from the rendered base symbol.
|
|
6767
|
+
// This preserves font metrics from font wrappers like \mathbb.
|
|
6768
|
+
skew = (_getBaseSymbol$skew = (_getBaseSymbol = getBaseSymbol(body)) == null ? void 0 : _getBaseSymbol.skew) != null ? _getBaseSymbol$skew : 0;
|
|
6757
6769
|
}
|
|
6758
6770
|
var accentBelow = group.label === "\\c";
|
|
6759
6771
|
// calculate the amount of space between the body and the accent
|
|
@@ -13757,10 +13769,6 @@ defineMacro("\u210C", "\\mathfrak{H}");
|
|
|
13757
13769
|
defineMacro("\u2128", "\\mathfrak{Z}");
|
|
13758
13770
|
// Define \Bbbk with a macro that works in both HTML and MathML.
|
|
13759
13771
|
defineMacro("\\Bbbk", "\\Bbb{k}");
|
|
13760
|
-
// Unicode middle dot
|
|
13761
|
-
// The KaTeX fonts do not contain U+00B7. Instead, \cdotp displays
|
|
13762
|
-
// the dot at U+22C5 and gives it punct spacing.
|
|
13763
|
-
defineMacro("\u00b7", "\\cdotp");
|
|
13764
13772
|
// \llap and \rlap render their contents in text mode
|
|
13765
13773
|
defineMacro("\\llap", "\\mathllap{\\textrm{#1}}");
|
|
13766
13774
|
defineMacro("\\rlap", "\\mathrlap{\\textrm{#1}}");
|
|
@@ -16361,7 +16369,7 @@ var renderToHTMLTree = function renderToHTMLTree(expression, options) {
|
|
|
16361
16369
|
return renderError(error, expression, settings);
|
|
16362
16370
|
}
|
|
16363
16371
|
};
|
|
16364
|
-
var version = "0.16.
|
|
16372
|
+
var version = "0.16.39";
|
|
16365
16373
|
var __domTree = {
|
|
16366
16374
|
Span,
|
|
16367
16375
|
Anchor,
|
package/package.json
CHANGED
package/src/domTree.ts
CHANGED
|
@@ -621,3 +621,16 @@ export function assertSpan(
|
|
|
621
621
|
throw new Error(`Expected span<HtmlDomNode> but got ${String(group)}.`);
|
|
622
622
|
}
|
|
623
623
|
}
|
|
624
|
+
|
|
625
|
+
/**
|
|
626
|
+
* Whether an HtmlDomNode has HtmlDomNode children.
|
|
627
|
+
* HtmlDomNode is a base type representing a union of
|
|
628
|
+
* SymbolNode, SvgSpan, DomSpan, Anchor, and documentFragment.
|
|
629
|
+
* In the last three cases, the children are HtmlDomNode[].
|
|
630
|
+
*/
|
|
631
|
+
export const hasHtmlDomChildren = (
|
|
632
|
+
node: HtmlDomNode,
|
|
633
|
+
): node is DomSpan | Anchor | documentFragment =>
|
|
634
|
+
node instanceof Span ||
|
|
635
|
+
node instanceof Anchor ||
|
|
636
|
+
node instanceof DocumentFragment;
|
package/src/functions/accent.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import defineFunction, {normalizeArgument} from "../defineFunction";
|
|
2
2
|
import {makeOrd, makeSpan, makeVList, staticSvg, svgData} from "../buildCommon";
|
|
3
|
-
import {
|
|
3
|
+
import {isCharacterBox} from "../utils";
|
|
4
4
|
import {MathNode} from "../mathMLTree";
|
|
5
5
|
import {stretchyMathML, stretchySvg} from "../stretchy";
|
|
6
6
|
import {assertNodeType} from "../parseNode";
|
|
7
|
-
import {assertSpan, assertSymbolDomNode} from "../domTree";
|
|
7
|
+
import {assertSpan, assertSymbolDomNode, hasHtmlDomChildren, SymbolNode} from "../domTree";
|
|
8
8
|
import {makeEm} from "../units";
|
|
9
9
|
|
|
10
10
|
import * as html from "../buildHTML";
|
|
@@ -12,6 +12,16 @@ import * as mml from "../buildMathML";
|
|
|
12
12
|
|
|
13
13
|
import type {ParseNode, AnyParseNode} from "../parseNode";
|
|
14
14
|
import type {HtmlBuilderSupSub, MathMLBuilder} from "../defineFunction";
|
|
15
|
+
import type {HtmlDomNode} from "../domTree";
|
|
16
|
+
|
|
17
|
+
const getBaseSymbol = (group: HtmlDomNode): SymbolNode | undefined => {
|
|
18
|
+
if (group instanceof SymbolNode) {
|
|
19
|
+
return group;
|
|
20
|
+
}
|
|
21
|
+
if (hasHtmlDomChildren(group) && group.children.length === 1) {
|
|
22
|
+
return getBaseSymbol(group.children[0]);
|
|
23
|
+
}
|
|
24
|
+
};
|
|
15
25
|
|
|
16
26
|
// NOTE: Unlike most `htmlBuilder`s, this one handles not only "accent", but
|
|
17
27
|
// also "supsub" since an accent can affect super/subscripting.
|
|
@@ -61,17 +71,9 @@ export const htmlBuilder: HtmlBuilderSupSub<"accent"> = (grp, options) => {
|
|
|
61
71
|
// and the skewchar.
|
|
62
72
|
let skew = 0;
|
|
63
73
|
if (mustShift) {
|
|
64
|
-
//
|
|
65
|
-
//
|
|
66
|
-
|
|
67
|
-
// Then, we render its group to get the symbol inside it
|
|
68
|
-
const baseGroup = html.buildGroup(baseChar, options.havingCrampedStyle());
|
|
69
|
-
// Finally, we pull the skew off of the symbol.
|
|
70
|
-
skew = assertSymbolDomNode(baseGroup).skew;
|
|
71
|
-
// Note that we now throw away baseGroup, because the layers we
|
|
72
|
-
// removed with getBaseElem might contain things like \color which
|
|
73
|
-
// we can't get rid of.
|
|
74
|
-
// TODO(emily): Find a better way to get the skew
|
|
74
|
+
// Read the skew from the rendered base symbol.
|
|
75
|
+
// This preserves font metrics from font wrappers like \mathbb.
|
|
76
|
+
skew = getBaseSymbol(body)?.skew ?? 0;
|
|
75
77
|
}
|
|
76
78
|
|
|
77
79
|
const accentBelow = group.label === "\\c";
|
package/src/macros.ts
CHANGED
|
@@ -269,11 +269,6 @@ defineMacro("\u2128", "\\mathfrak{Z}");
|
|
|
269
269
|
// Define \Bbbk with a macro that works in both HTML and MathML.
|
|
270
270
|
defineMacro("\\Bbbk", "\\Bbb{k}");
|
|
271
271
|
|
|
272
|
-
// Unicode middle dot
|
|
273
|
-
// The KaTeX fonts do not contain U+00B7. Instead, \cdotp displays
|
|
274
|
-
// the dot at U+22C5 and gives it punct spacing.
|
|
275
|
-
defineMacro("\u00b7", "\\cdotp");
|
|
276
|
-
|
|
277
272
|
// \llap and \rlap render their contents in text mode
|
|
278
273
|
defineMacro("\\llap", "\\mathllap{\\textrm{#1}}");
|
|
279
274
|
defineMacro("\\rlap", "\\mathrlap{\\textrm{#1}}");
|
package/src/symbols.ts
CHANGED
|
@@ -122,6 +122,10 @@ defineSymbol(math, main, rel, "\u220b", "\\owns");
|
|
|
122
122
|
// Punctuation
|
|
123
123
|
defineSymbol(math, main, punct, "\u002e", "\\ldotp");
|
|
124
124
|
defineSymbol(math, main, punct, "\u22c5", "\\cdotp");
|
|
125
|
+
// The KaTeX fonts do not contain U+00B7. Use the centered dot glyph at U+22C5
|
|
126
|
+
// in both modes, but keep math-mode punctuation spacing only in math mode.
|
|
127
|
+
defineSymbol(math, main, punct, "\u22c5", "\u00b7");
|
|
128
|
+
defineSymbol(text, main, textord, "\u22c5", "\u00b7");
|
|
125
129
|
|
|
126
130
|
// Misc Symbols
|
|
127
131
|
defineSymbol(math, main, textord, "\u0023", "\\#");
|