katex 0.16.1 → 0.16.3
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/contrib/auto-render/auto-render.js +20 -1
- package/contrib/auto-render/test/auto-render-spec.js +88 -17
- 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.js +5 -0
- package/dist/README.md +3 -3
- package/dist/contrib/auto-render.js +23 -1
- package/dist/contrib/auto-render.min.js +1 -1
- package/dist/contrib/auto-render.mjs +23 -1
- package/dist/contrib/render-a11y-string.js +6 -0
- package/dist/contrib/render-a11y-string.min.js +1 -1
- package/dist/contrib/render-a11y-string.mjs +6 -0
- package/dist/katex.css +1 -1
- package/dist/katex.js +223 -179
- package/dist/katex.min.css +1 -1
- package/dist/katex.min.js +1 -1
- package/dist/katex.mjs +264 -221
- package/package.json +1 -1
- package/src/Parser.js +1 -1
- package/src/buildCommon.js +1 -1
- package/src/buildMathML.js +2 -2
- package/src/domTree.js +1 -0
- package/src/environments/array.js +6 -1
- package/src/functions/enclose.js +1 -1
- package/src/functions/mclass.js +1 -1
- package/src/functions/op.js +1 -1
- package/src/functions/pmb.js +44 -0
- package/src/functions.js +1 -0
- package/src/macros.js +1 -9
- package/src/parseNode.js +7 -0
- package/src/stretchy.js +1 -1
package/package.json
CHANGED
package/src/Parser.js
CHANGED
|
@@ -922,7 +922,7 @@ export default class Parser {
|
|
|
922
922
|
`Accented Unicode text character "${text[0]}" used in ` +
|
|
923
923
|
`math mode`, nucleus);
|
|
924
924
|
}
|
|
925
|
-
text = unicodeSymbols[text[0]] + text.
|
|
925
|
+
text = unicodeSymbols[text[0]] + text.slice(1);
|
|
926
926
|
}
|
|
927
927
|
// Strip off any combining characters
|
|
928
928
|
const match = combiningDiacriticalMarksEndRegex.exec(text);
|
package/src/buildCommon.js
CHANGED
|
@@ -190,7 +190,7 @@ const makeOrd = function<NODETYPE: "spacing" | "mathord" | "textord">(
|
|
|
190
190
|
return makeSymbol(text, fontName, mode, options,
|
|
191
191
|
classes.concat(fontClasses));
|
|
192
192
|
} else if (ligatures.hasOwnProperty(text) &&
|
|
193
|
-
fontName.
|
|
193
|
+
fontName.slice(0, 10) === "Typewriter") {
|
|
194
194
|
// Deconstruct ligatures in monospace fonts (\texttt, \tt).
|
|
195
195
|
const parts = [];
|
|
196
196
|
for (let i = 0; i < text.length; i++) {
|
package/src/buildMathML.js
CHANGED
|
@@ -32,8 +32,8 @@ export const makeText = function(
|
|
|
32
32
|
if (symbols[mode][text] && symbols[mode][text].replace &&
|
|
33
33
|
text.charCodeAt(0) !== 0xD835 &&
|
|
34
34
|
!(ligatures.hasOwnProperty(text) && options &&
|
|
35
|
-
((options.fontFamily && options.fontFamily.
|
|
36
|
-
(options.font && options.font.
|
|
35
|
+
((options.fontFamily && options.fontFamily.slice(4, 6) === "tt") ||
|
|
36
|
+
(options.font && options.font.slice(4, 6) === "tt")))) {
|
|
37
37
|
text = symbols[mode][text].replace;
|
|
38
38
|
}
|
|
39
39
|
|
package/src/domTree.js
CHANGED
|
@@ -39,6 +39,11 @@ function getHLines(parser: Parser): boolean[] {
|
|
|
39
39
|
const hlineInfo = [];
|
|
40
40
|
parser.consumeSpaces();
|
|
41
41
|
let nxt = parser.fetch().text;
|
|
42
|
+
if (nxt === "\\relax") { // \relax is an artifact of the \cr macro below
|
|
43
|
+
parser.consume();
|
|
44
|
+
parser.consumeSpaces();
|
|
45
|
+
nxt = parser.fetch().text;
|
|
46
|
+
}
|
|
42
47
|
while (nxt === "\\hline" || nxt === "\\hdashline") {
|
|
43
48
|
parser.consume();
|
|
44
49
|
hlineInfo.push(nxt === "\\hdashline");
|
|
@@ -256,7 +261,7 @@ function parseArray(
|
|
|
256
261
|
// Decides on a style for cells in an array according to whether the given
|
|
257
262
|
// environment name starts with the letter 'd'.
|
|
258
263
|
function dCellStyle(envName): StyleStr {
|
|
259
|
-
if (envName.
|
|
264
|
+
if (envName.slice(0, 1) === "d") {
|
|
260
265
|
return "display";
|
|
261
266
|
} else {
|
|
262
267
|
return "text";
|
package/src/functions/enclose.js
CHANGED
|
@@ -20,7 +20,7 @@ const htmlBuilder = (group, options) => {
|
|
|
20
20
|
const inner = buildCommon.wrapFragment(
|
|
21
21
|
html.buildGroup(group.body, options), options);
|
|
22
22
|
|
|
23
|
-
const label = group.label.
|
|
23
|
+
const label = group.label.slice(1);
|
|
24
24
|
let scale = options.sizeMultiplier;
|
|
25
25
|
let img;
|
|
26
26
|
let imgShift = 0;
|
package/src/functions/mclass.js
CHANGED
|
@@ -75,7 +75,7 @@ defineFunction({
|
|
|
75
75
|
return {
|
|
76
76
|
type: "mclass",
|
|
77
77
|
mode: parser.mode,
|
|
78
|
-
mclass: "m" + funcName.
|
|
78
|
+
mclass: "m" + funcName.slice(5), // TODO(kevinb): don't prefix with 'm'
|
|
79
79
|
body: ordargument(body),
|
|
80
80
|
isCharacterBox: utils.isCharacterBox(body),
|
|
81
81
|
};
|
package/src/functions/op.js
CHANGED
|
@@ -61,7 +61,7 @@ export const htmlBuilder: HtmlBuilderSupSub<"op"> = (grp, options) => {
|
|
|
61
61
|
if (group.name === "\\oiint" || group.name === "\\oiiint") {
|
|
62
62
|
// No font glyphs yet, so use a glyph w/o the oval.
|
|
63
63
|
// TODO: When font glyphs are available, delete this code.
|
|
64
|
-
stash = group.name.
|
|
64
|
+
stash = group.name.slice(1);
|
|
65
65
|
group.name = stash === "oiint" ? "\\iint" : "\\iiint";
|
|
66
66
|
}
|
|
67
67
|
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
// @flow
|
|
2
|
+
import defineFunction, {ordargument} from "../defineFunction";
|
|
3
|
+
import buildCommon from "../buildCommon";
|
|
4
|
+
import mathMLTree from "../mathMLTree";
|
|
5
|
+
import * as html from "../buildHTML";
|
|
6
|
+
import * as mml from "../buildMathML";
|
|
7
|
+
import {binrelClass} from "./mclass";
|
|
8
|
+
|
|
9
|
+
import type {ParseNode} from "../parseNode";
|
|
10
|
+
|
|
11
|
+
// \pmb is a simulation of bold font.
|
|
12
|
+
// The version of \pmb in ambsy.sty works by typesetting three copies
|
|
13
|
+
// with small offsets. We use CSS text-shadow.
|
|
14
|
+
// It's a hack. Not as good as a real bold font. Better than nothing.
|
|
15
|
+
|
|
16
|
+
defineFunction({
|
|
17
|
+
type: "pmb",
|
|
18
|
+
names: ["\\pmb"],
|
|
19
|
+
props: {
|
|
20
|
+
numArgs: 1,
|
|
21
|
+
allowedInText: true,
|
|
22
|
+
},
|
|
23
|
+
handler({parser}, args) {
|
|
24
|
+
return {
|
|
25
|
+
type: "pmb",
|
|
26
|
+
mode: parser.mode,
|
|
27
|
+
mclass: binrelClass(args[0]),
|
|
28
|
+
body: ordargument(args[0]),
|
|
29
|
+
};
|
|
30
|
+
},
|
|
31
|
+
htmlBuilder(group: ParseNode<"pmb">, options) {
|
|
32
|
+
const elements = html.buildExpression(group.body, options, true);
|
|
33
|
+
const node = buildCommon.makeSpan([group.mclass], elements, options);
|
|
34
|
+
node.style.textShadow = "0.02em 0.01em 0.04px";
|
|
35
|
+
return node;
|
|
36
|
+
},
|
|
37
|
+
mathmlBuilder(group: ParseNode<"pmb">, style) {
|
|
38
|
+
const inner = mml.buildExpression(group.body, style);
|
|
39
|
+
// Wrap with an <mstyle> element.
|
|
40
|
+
const node = new mathMLTree.MathNode("mstyle", inner);
|
|
41
|
+
node.setAttribute("style", "text-shadow: 0.02em 0.01em 0.04px");
|
|
42
|
+
return node;
|
|
43
|
+
},
|
|
44
|
+
});
|
package/src/functions.js
CHANGED
package/src/macros.js
CHANGED
|
@@ -447,7 +447,7 @@ defineMacro("\\dots", function(context) {
|
|
|
447
447
|
const next = context.expandAfterFuture().text;
|
|
448
448
|
if (next in dotsByToken) {
|
|
449
449
|
thedots = dotsByToken[next];
|
|
450
|
-
} else if (next.
|
|
450
|
+
} else if (next.slice(0, 4) === '\\not') {
|
|
451
451
|
thedots = '\\dotsb';
|
|
452
452
|
} else if (next in symbols.math) {
|
|
453
453
|
if (utils.contains(['bin', 'rel'], symbols.math[next].group)) {
|
|
@@ -597,14 +597,6 @@ defineMacro("\\mod", "\\allowbreak" +
|
|
|
597
597
|
"\\mathchoice{\\mkern18mu}{\\mkern12mu}{\\mkern12mu}{\\mkern12mu}" +
|
|
598
598
|
"{\\rm mod}\\,\\,#1");
|
|
599
599
|
|
|
600
|
-
// \pmb -- A simulation of bold.
|
|
601
|
-
// The version in ambsy.sty works by typesetting three copies of the argument
|
|
602
|
-
// with small offsets. We use two copies. We omit the vertical offset because
|
|
603
|
-
// of rendering problems that makeVList encounters in Safari.
|
|
604
|
-
defineMacro("\\pmb", "\\html@mathml{" +
|
|
605
|
-
"\\@binrel{#1}{\\mathrlap{#1}\\kern0.5px#1}}" +
|
|
606
|
-
"{\\mathbf{#1}}");
|
|
607
|
-
|
|
608
600
|
//////////////////////////////////////////////////////////////////////
|
|
609
601
|
// LaTeX source2e
|
|
610
602
|
|
package/src/parseNode.js
CHANGED
|
@@ -414,6 +414,13 @@ type ParseNodeTypes = {
|
|
|
414
414
|
loc?: ?SourceLocation,
|
|
415
415
|
body: AnyParseNode,
|
|
416
416
|
|},
|
|
417
|
+
"pmb": {|
|
|
418
|
+
type: "pmb",
|
|
419
|
+
mode: Mode,
|
|
420
|
+
loc?: ?SourceLocation,
|
|
421
|
+
mclass: string,
|
|
422
|
+
body: AnyParseNode[],
|
|
423
|
+
|},
|
|
417
424
|
"raisebox": {|
|
|
418
425
|
type: "raisebox",
|
|
419
426
|
mode: Mode,
|
package/src/stretchy.js
CHANGED
|
@@ -191,7 +191,7 @@ const svgSpan = function(
|
|
|
191
191
|
height: number,
|
|
192
192
|
} {
|
|
193
193
|
let viewBoxWidth = 400000; // default
|
|
194
|
-
const label = group.label.
|
|
194
|
+
const label = group.label.slice(1);
|
|
195
195
|
if (utils.contains(["widehat", "widecheck", "widetilde", "utilde"],
|
|
196
196
|
label)) {
|
|
197
197
|
// Each type in the `if` statement corresponds to one of the ParseNode
|