katex 0.16.1 → 0.16.2

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/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.substr(1);
925
+ text = unicodeSymbols[text[0]] + text.slice(1);
926
926
  }
927
927
  // Strip off any combining characters
928
928
  const match = combiningDiacriticalMarksEndRegex.exec(text);
@@ -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.substr(0, 10) === "Typewriter") {
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++) {
@@ -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.substr(4, 2) === "tt") ||
36
- (options.font && options.font.substr(4, 2) === "tt")))) {
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
@@ -153,6 +153,7 @@ export type CssStyle = $Shape<{
153
153
  minWidth: string,
154
154
  paddingLeft: string,
155
155
  position: string,
156
+ textShadow: string,
156
157
  top: string,
157
158
  width: string,
158
159
  verticalAlign: string,
@@ -256,7 +256,7 @@ function parseArray(
256
256
  // Decides on a style for cells in an array according to whether the given
257
257
  // environment name starts with the letter 'd'.
258
258
  function dCellStyle(envName): StyleStr {
259
- if (envName.substr(0, 1) === "d") {
259
+ if (envName.slice(0, 1) === "d") {
260
260
  return "display";
261
261
  } else {
262
262
  return "text";
@@ -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.substr(1);
23
+ const label = group.label.slice(1);
24
24
  let scale = options.sizeMultiplier;
25
25
  let img;
26
26
  let imgShift = 0;
@@ -75,7 +75,7 @@ defineFunction({
75
75
  return {
76
76
  type: "mclass",
77
77
  mode: parser.mode,
78
- mclass: "m" + funcName.substr(5), // TODO(kevinb): don't prefix with 'm'
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
  };
@@ -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.substr(1);
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
@@ -10,6 +10,7 @@ export default functions;
10
10
  import "./functions/accent";
11
11
  import "./functions/accentunder";
12
12
  import "./functions/arrow";
13
+ import "./functions/pmb";
13
14
  import "./environments/cd";
14
15
  import "./functions/char";
15
16
  import "./functions/color";
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.substr(0, 4) === '\\not') {
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.substr(1);
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