katex 0.10.1 → 0.12.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.
Files changed (144) hide show
  1. package/CHANGELOG.md +141 -0
  2. package/LICENSE +1 -1
  3. package/README.md +6 -6
  4. package/cli.js +0 -0
  5. package/contrib/auto-render/auto-render.js +12 -3
  6. package/contrib/copy-tex/README.md +3 -5
  7. package/contrib/mathtex-script-type/README.md +12 -14
  8. package/contrib/mhchem/README.md +3 -1
  9. package/contrib/render-a11y-string/render-a11y-string.js +712 -0
  10. package/contrib/render-a11y-string/test/render-a11y-string-spec.js +526 -0
  11. package/dist/README.md +6 -6
  12. package/dist/contrib/auto-render.js +14 -3
  13. package/dist/contrib/auto-render.min.js +1 -1
  14. package/dist/contrib/auto-render.mjs +14 -3
  15. package/dist/contrib/mhchem.min.js +1 -1
  16. package/dist/contrib/render-a11y-string.js +870 -0
  17. package/dist/contrib/render-a11y-string.min.js +1 -0
  18. package/dist/contrib/render-a11y-string.mjs +753 -0
  19. package/dist/fonts/KaTeX_AMS-Regular.ttf +0 -0
  20. package/dist/fonts/KaTeX_AMS-Regular.woff +0 -0
  21. package/dist/fonts/KaTeX_AMS-Regular.woff2 +0 -0
  22. package/dist/fonts/KaTeX_Caligraphic-Bold.ttf +0 -0
  23. package/dist/fonts/KaTeX_Caligraphic-Bold.woff +0 -0
  24. package/dist/fonts/KaTeX_Caligraphic-Bold.woff2 +0 -0
  25. package/dist/fonts/KaTeX_Caligraphic-Regular.ttf +0 -0
  26. package/dist/fonts/KaTeX_Caligraphic-Regular.woff +0 -0
  27. package/dist/fonts/KaTeX_Caligraphic-Regular.woff2 +0 -0
  28. package/dist/fonts/KaTeX_Fraktur-Bold.ttf +0 -0
  29. package/dist/fonts/KaTeX_Fraktur-Bold.woff +0 -0
  30. package/dist/fonts/KaTeX_Fraktur-Bold.woff2 +0 -0
  31. package/dist/fonts/KaTeX_Fraktur-Regular.ttf +0 -0
  32. package/dist/fonts/KaTeX_Fraktur-Regular.woff +0 -0
  33. package/dist/fonts/KaTeX_Fraktur-Regular.woff2 +0 -0
  34. package/dist/fonts/KaTeX_Main-Bold.ttf +0 -0
  35. package/dist/fonts/KaTeX_Main-Bold.woff +0 -0
  36. package/dist/fonts/KaTeX_Main-Bold.woff2 +0 -0
  37. package/dist/fonts/KaTeX_Main-BoldItalic.ttf +0 -0
  38. package/dist/fonts/KaTeX_Main-BoldItalic.woff +0 -0
  39. package/dist/fonts/KaTeX_Main-BoldItalic.woff2 +0 -0
  40. package/dist/fonts/KaTeX_Main-Italic.ttf +0 -0
  41. package/dist/fonts/KaTeX_Main-Italic.woff +0 -0
  42. package/dist/fonts/KaTeX_Main-Italic.woff2 +0 -0
  43. package/dist/fonts/KaTeX_Main-Regular.ttf +0 -0
  44. package/dist/fonts/KaTeX_Main-Regular.woff +0 -0
  45. package/dist/fonts/KaTeX_Main-Regular.woff2 +0 -0
  46. package/dist/fonts/KaTeX_Math-BoldItalic.ttf +0 -0
  47. package/dist/fonts/KaTeX_Math-BoldItalic.woff +0 -0
  48. package/dist/fonts/KaTeX_Math-BoldItalic.woff2 +0 -0
  49. package/dist/fonts/KaTeX_Math-Italic.ttf +0 -0
  50. package/dist/fonts/KaTeX_Math-Italic.woff +0 -0
  51. package/dist/fonts/KaTeX_Math-Italic.woff2 +0 -0
  52. package/dist/fonts/KaTeX_SansSerif-Bold.ttf +0 -0
  53. package/dist/fonts/KaTeX_SansSerif-Bold.woff +0 -0
  54. package/dist/fonts/KaTeX_SansSerif-Bold.woff2 +0 -0
  55. package/dist/fonts/KaTeX_SansSerif-Italic.ttf +0 -0
  56. package/dist/fonts/KaTeX_SansSerif-Italic.woff +0 -0
  57. package/dist/fonts/KaTeX_SansSerif-Italic.woff2 +0 -0
  58. package/dist/fonts/KaTeX_SansSerif-Regular.ttf +0 -0
  59. package/dist/fonts/KaTeX_SansSerif-Regular.woff +0 -0
  60. package/dist/fonts/KaTeX_SansSerif-Regular.woff2 +0 -0
  61. package/dist/fonts/KaTeX_Script-Regular.ttf +0 -0
  62. package/dist/fonts/KaTeX_Script-Regular.woff +0 -0
  63. package/dist/fonts/KaTeX_Script-Regular.woff2 +0 -0
  64. package/dist/fonts/KaTeX_Size1-Regular.ttf +0 -0
  65. package/dist/fonts/KaTeX_Size1-Regular.woff +0 -0
  66. package/dist/fonts/KaTeX_Size1-Regular.woff2 +0 -0
  67. package/dist/fonts/KaTeX_Size2-Regular.ttf +0 -0
  68. package/dist/fonts/KaTeX_Size2-Regular.woff +0 -0
  69. package/dist/fonts/KaTeX_Size2-Regular.woff2 +0 -0
  70. package/dist/fonts/KaTeX_Size3-Regular.ttf +0 -0
  71. package/dist/fonts/KaTeX_Size3-Regular.woff +0 -0
  72. package/dist/fonts/KaTeX_Size3-Regular.woff2 +0 -0
  73. package/dist/fonts/KaTeX_Size4-Regular.ttf +0 -0
  74. package/dist/fonts/KaTeX_Size4-Regular.woff +0 -0
  75. package/dist/fonts/KaTeX_Size4-Regular.woff2 +0 -0
  76. package/dist/fonts/KaTeX_Typewriter-Regular.ttf +0 -0
  77. package/dist/fonts/KaTeX_Typewriter-Regular.woff +0 -0
  78. package/dist/fonts/KaTeX_Typewriter-Regular.woff2 +0 -0
  79. package/dist/katex.css +34 -10
  80. package/dist/katex.js +2906 -2115
  81. package/dist/katex.min.css +1 -1
  82. package/dist/katex.min.js +1 -1
  83. package/dist/katex.mjs +2809 -2020
  84. package/package.json +12 -11
  85. package/src/Lexer.js +1 -0
  86. package/src/MacroExpander.js +39 -10
  87. package/src/Options.js +15 -75
  88. package/src/Parser.js +152 -115
  89. package/src/Settings.js +70 -7
  90. package/src/Token.js +2 -0
  91. package/src/buildCommon.js +24 -90
  92. package/src/buildHTML.js +31 -31
  93. package/src/buildMathML.js +52 -9
  94. package/src/buildTree.js +13 -6
  95. package/src/defineFunction.js +7 -22
  96. package/src/delimiter.js +66 -27
  97. package/src/domTree.js +71 -4
  98. package/src/environments/array.js +235 -25
  99. package/src/fontMetrics.js +11 -2
  100. package/src/functions/accent.js +9 -9
  101. package/src/functions/accentunder.js +2 -2
  102. package/src/functions/arrow.js +15 -5
  103. package/src/functions/color.js +9 -38
  104. package/src/functions/def.js +184 -0
  105. package/src/functions/delimsizing.js +32 -8
  106. package/src/functions/enclose.js +33 -6
  107. package/src/functions/font.js +4 -1
  108. package/src/functions/genfrac.js +39 -27
  109. package/src/functions/horizBrace.js +6 -7
  110. package/src/functions/href.js +16 -0
  111. package/src/functions/html.js +102 -0
  112. package/src/functions/includegraphics.js +153 -0
  113. package/src/functions/lap.js +4 -7
  114. package/src/functions/math.js +1 -5
  115. package/src/functions/mclass.js +41 -2
  116. package/src/functions/op.js +27 -111
  117. package/src/functions/operatorname.js +136 -92
  118. package/src/functions/ordgroup.js +1 -1
  119. package/src/functions/overline.js +3 -2
  120. package/src/functions/phantom.js +5 -2
  121. package/src/functions/raisebox.js +4 -16
  122. package/src/functions/rule.js +20 -9
  123. package/src/functions/styling.js +0 -9
  124. package/src/functions/supsub.js +27 -7
  125. package/src/functions/symbolsOp.js +4 -0
  126. package/src/functions/tag.js +20 -4
  127. package/src/functions/text.js +4 -3
  128. package/src/functions/underline.js +3 -2
  129. package/src/functions/utils/assembleSupSub.js +110 -0
  130. package/src/functions.js +3 -0
  131. package/src/katex.less +45 -9
  132. package/src/macros.js +259 -98
  133. package/src/mathMLTree.js +6 -4
  134. package/src/parseNode.js +37 -57
  135. package/src/stretchy.js +3 -1
  136. package/src/svgGeometry.js +136 -44
  137. package/src/symbols.js +52 -69
  138. package/src/tree.js +2 -2
  139. package/src/types.js +2 -1
  140. package/src/unicodeAccents.js +3 -1
  141. package/src/unicodeSymbols.js +30 -321
  142. package/src/utils.js +10 -0
  143. package/src/wide-character.js +2 -2
  144. package/src/unicodeMake.js +0 -70
package/src/parseNode.js CHANGED
@@ -1,7 +1,7 @@
1
1
  // @flow
2
2
  import {NON_ATOMS} from "./symbols";
3
3
  import type SourceLocation from "./SourceLocation";
4
- import type {AlignSpec} from "./environments/array";
4
+ import type {AlignSpec, ColSeparationType} from "./environments/array";
5
5
  import type {Atom} from "./symbols";
6
6
  import type {Mode, StyleStr} from "./types";
7
7
  import type {Token} from "./Token";
@@ -19,6 +19,9 @@ export type SymbolParseNode =
19
19
  ParseNode<"spacing"> |
20
20
  ParseNode<"textord">;
21
21
 
22
+ // ParseNode from `Parser.formatUnsupportedCmd`
23
+ export type UnsupportedCmdParseNode = ParseNode<"color">;
24
+
22
25
  // Union of all possible `ParseNode<>` types.
23
26
  export type AnyParseNode = $Values<ParseNodeTypes>;
24
27
 
@@ -28,6 +31,7 @@ type ParseNodeTypes = {
28
31
  type: "array",
29
32
  mode: Mode,
30
33
  loc?: ?SourceLocation,
34
+ colSeparationType?: ColSeparationType,
31
35
  hskipBeforeAndAfter?: boolean,
32
36
  addJot?: boolean,
33
37
  cols?: AlignSpec[],
@@ -60,6 +64,7 @@ type ParseNodeTypes = {
60
64
  limits: boolean,
61
65
  alwaysHandleSupSub?: boolean,
62
66
  suppressBaseShift?: boolean,
67
+ parentIsSupSub: boolean,
63
68
  symbol: boolean,
64
69
  name: string,
65
70
  body?: void,
@@ -70,6 +75,7 @@ type ParseNodeTypes = {
70
75
  limits: boolean,
71
76
  alwaysHandleSupSub?: boolean,
72
77
  suppressBaseShift?: boolean,
78
+ parentIsSupSub: boolean,
73
79
  symbol: false, // If 'symbol' is true, `body` *must* be set.
74
80
  name?: void,
75
81
  body: AnyParseNode[],
@@ -264,6 +270,13 @@ type ParseNodeTypes = {
264
270
  href: string,
265
271
  body: AnyParseNode[],
266
272
  |},
273
+ "html": {|
274
+ type: "html",
275
+ mode: Mode,
276
+ loc?: ?SourceLocation,
277
+ attributes: {[string]: string},
278
+ body: AnyParseNode[],
279
+ |},
267
280
  "htmlmathml": {|
268
281
  type: "htmlmathml",
269
282
  mode: Mode,
@@ -271,6 +284,16 @@ type ParseNodeTypes = {
271
284
  html: AnyParseNode[],
272
285
  mathml: AnyParseNode[],
273
286
  |},
287
+ "includegraphics": {|
288
+ type: "includegraphics",
289
+ mode: Mode,
290
+ loc?: ?SourceLocation,
291
+ alt: string,
292
+ width: Measurement,
293
+ height: Measurement,
294
+ totalheight: Measurement,
295
+ src: string,
296
+ |},
274
297
  "infix": {|
275
298
  type: "infix",
276
299
  mode: Mode,
@@ -279,6 +302,11 @@ type ParseNodeTypes = {
279
302
  size?: Measurement,
280
303
  token: ?Token,
281
304
  |},
305
+ "internal": {|
306
+ type: "internal",
307
+ mode: Mode,
308
+ loc?: ?SourceLocation,
309
+ |},
282
310
  "kern": {|
283
311
  type: "kern",
284
312
  mode: Mode,
@@ -299,12 +327,14 @@ type ParseNodeTypes = {
299
327
  body: AnyParseNode[],
300
328
  left: string,
301
329
  right: string,
330
+ rightColor: ?string, // undefined means "inherit"
302
331
  |},
303
332
  "leftright-right": {|
304
333
  type: "leftright-right",
305
334
  mode: Mode,
306
335
  loc?: ?SourceLocation,
307
336
  delim: string,
337
+ color: ?string, // undefined means "inherit"
308
338
  |},
309
339
  "mathchoice": {|
310
340
  type: "mathchoice",
@@ -327,12 +357,16 @@ type ParseNodeTypes = {
327
357
  loc?: ?SourceLocation,
328
358
  mclass: string,
329
359
  body: AnyParseNode[],
360
+ isCharacterBox: boolean,
330
361
  |},
331
362
  "operatorname": {|
332
363
  type: "operatorname",
333
364
  mode: Mode,
334
365
  loc?: ?SourceLocation,
335
366
  body: AnyParseNode[],
367
+ alwaysHandleSupSub: boolean,
368
+ limits: boolean,
369
+ parentIsSupSub: boolean,
336
370
  |},
337
371
  "overline": {|
338
372
  type: "overline",
@@ -419,66 +453,12 @@ export function assertNodeType<NODETYPE: NodeType>(
419
453
  node: ?AnyParseNode,
420
454
  type: NODETYPE,
421
455
  ): ParseNode<NODETYPE> {
422
- const typedNode = checkNodeType(node, type);
423
- if (!typedNode) {
456
+ if (!node || node.type !== type) {
424
457
  throw new Error(
425
458
  `Expected node of type ${type}, but got ` +
426
459
  (node ? `node of type ${node.type}` : String(node)));
427
460
  }
428
- // $FlowFixMe: Unsure why.
429
- return typedNode;
430
- }
431
-
432
- /**
433
- * Returns the node more strictly typed iff it is of the given type. Otherwise,
434
- * returns null.
435
- */
436
- export function checkNodeType<NODETYPE: NodeType>(
437
- node: ?AnyParseNode,
438
- type: NODETYPE,
439
- ): ?ParseNode<NODETYPE> {
440
- if (node && node.type === type) {
441
- // The definition of ParseNode<TYPE> doesn't communicate to flow that
442
- // `type: TYPE` (as that's not explicitly mentioned anywhere), though that
443
- // happens to be true for all our value types.
444
- // $FlowFixMe
445
- return node;
446
- }
447
- return null;
448
- }
449
-
450
- /**
451
- * Asserts that the node is of the given type and returns it with stricter
452
- * typing. Throws if the node's type does not match.
453
- */
454
- export function assertAtomFamily(
455
- node: ?AnyParseNode,
456
- family: Atom,
457
- ): ParseNode<"atom"> {
458
- const typedNode = checkAtomFamily(node, family);
459
- if (!typedNode) {
460
- throw new Error(
461
- `Expected node of type "atom" and family "${family}", but got ` +
462
- (node ?
463
- (node.type === "atom" ?
464
- `atom of family ${node.family}` :
465
- `node of type ${node.type}`) :
466
- String(node)));
467
- }
468
- return typedNode;
469
- }
470
-
471
- /**
472
- * Returns the node more strictly typed iff it is of the given type. Otherwise,
473
- * returns null.
474
- */
475
- export function checkAtomFamily(
476
- node: ?AnyParseNode,
477
- family: Atom,
478
- ): ?ParseNode<"atom"> {
479
- return node && node.type === "atom" && node.family === family ?
480
- node :
481
- null;
461
+ return node;
482
462
  }
483
463
 
484
464
  /**
package/src/stretchy.js CHANGED
@@ -25,8 +25,10 @@ const stretchyCodePoint: {[string]: string} = {
25
25
  overrightarrow: "\u2192",
26
26
  underrightarrow: "\u2192",
27
27
  xrightarrow: "\u2192",
28
- underbrace: "\u23b5",
28
+ underbrace: "\u23df",
29
29
  overbrace: "\u23de",
30
+ overgroup: "\u23e0",
31
+ undergroup: "\u23e1",
30
32
  overleftrightarrow: "\u2194",
31
33
  underleftrightarrow: "\u2194",
32
34
  xleftrightarrow: "\u2194",
@@ -1,60 +1,155 @@
1
1
  // @flow
2
2
  /**
3
- * This file provides support to domTree.js
3
+ * This file provides support to domTree.js and delimiter.js.
4
4
  * It's a storehouse of path geometry for SVG images.
5
5
  */
6
6
 
7
7
  // In all paths below, the viewBox-to-em scale is 1000:1.
8
8
 
9
- const hLinePad = 80; // padding above a sqrt viniculum.
10
-
11
- const path: {[string]: string} = {
9
+ const hLinePad = 80; // padding above a sqrt viniculum. Prevents image cropping.
10
+
11
+ // The viniculum of a \sqrt can be made thicker by a KaTeX rendering option.
12
+ // Think of variable extraViniculum as two detours in the SVG path.
13
+ // The detour begins at the lower left of the area labeled extraViniculum below.
14
+ // The detour proceeds one extraViniculum distance up and slightly to the right,
15
+ // displacing the radiused corner between surd and viniculum. The radius is
16
+ // traversed as usual, then the detour resumes. It goes right, to the end of
17
+ // the very long viniculumn, then down one extraViniculum distance,
18
+ // after which it resumes regular path geometry for the radical.
19
+ /* viniculum
20
+ /
21
+ /▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒←extraViniculum
22
+ / █████████████████████←0.04em (40 unit) std viniculum thickness
23
+ / /
24
+ / /
25
+ / /\
26
+ / / surd
27
+ */
28
+
29
+ const sqrtMain = function(extraViniculum: number, hLinePad: number): string {
12
30
  // sqrtMain path geometry is from glyph U221A in the font KaTeX Main
13
- // All surds have 80 units padding above the viniculumn.
14
- sqrtMain: `M95,${622 + hLinePad}c-2.7,0,-7.17,-2.7,-13.5,-8c-5.8,-5.3,-9.5,
15
- -10,-9.5,-14c0,-2,0.3,-3.3,1,-4c1.3,-2.7,23.83,-20.7,67.5,-54c44.2,-33.3,65.8,
16
- -50.3,66.5,-51c1.3,-1.3,3,-2,5,-2c4.7,0,8.7,3.3,12,10s173,378,173,378c0.7,0,
17
- 35.3,-71,104,-213c68.7,-142,137.5,-285,206.5,-429c69,-144,104.5,-217.7,106.5,
18
- -221c5.3,-9.3,12,-14,20,-14H400000v40H845.2724s-225.272,467,-225.272,467
19
- s-235,486,-235,486c-2.7,4.7,-9,7,-19,7c-6,0,-10,-1,-12,-3s-194,-422,-194,-422
20
- s-65,47,-65,47z M834 ${hLinePad}H400000v40H845z`,
31
+ return `M95,${622 + extraViniculum + hLinePad}
32
+ c-2.7,0,-7.17,-2.7,-13.5,-8c-5.8,-5.3,-9.5,-10,-9.5,-14
33
+ c0,-2,0.3,-3.3,1,-4c1.3,-2.7,23.83,-20.7,67.5,-54
34
+ c44.2,-33.3,65.8,-50.3,66.5,-51c1.3,-1.3,3,-2,5,-2c4.7,0,8.7,3.3,12,10
35
+ s173,378,173,378c0.7,0,35.3,-71,104,-213c68.7,-142,137.5,-285,206.5,-429
36
+ c69,-144,104.5,-217.7,106.5,-221
37
+ l${extraViniculum / 2.075} -${extraViniculum}
38
+ c5.3,-9.3,12,-14,20,-14
39
+ H400000v${40 + extraViniculum}H845.2724
40
+ s-225.272,467,-225.272,467s-235,486,-235,486c-2.7,4.7,-9,7,-19,7
41
+ c-6,0,-10,-1,-12,-3s-194,-422,-194,-422s-65,47,-65,47z
42
+ M${834 + extraViniculum} ${hLinePad}h400000v${40 + extraViniculum}h-400000z`;
43
+ };
21
44
 
45
+ const sqrtSize1 = function(extraViniculum: number, hLinePad: number): string {
22
46
  // size1 is from glyph U221A in the font KaTeX_Size1-Regular
23
- sqrtSize1: `M263,${601 + hLinePad}c0.7,0,18,39.7,52,119c34,79.3,68.167,
24
- 158.7,102.5,238c34.3,79.3,51.8,119.3,52.5,120c340,-704.7,510.7,-1060.3,512,-1067
25
- c4.7,-7.3,11,-11,19,-11H40000v40H1012.3s-271.3,567,-271.3,567c-38.7,80.7,-84,
26
- 175,-136,283c-52,108,-89.167,185.3,-111.5,232c-22.3,46.7,-33.8,70.3,-34.5,71
27
- c-4.7,4.7,-12.3,7,-23,7s-12,-1,-12,-1s-109,-253,-109,-253c-72.7,-168,-109.3,
28
- -252,-110,-252c-10.7,8,-22,16.7,-34,26c-22,17.3,-33.3,26,-34,26s-26,-26,-26,-26
29
- s76,-59,76,-59s76,-60,76,-60z M1001 ${hLinePad}H40000v40H1012z`,
47
+ return `M263,${601 + extraViniculum + hLinePad}c0.7,0,18,39.7,52,119
48
+ c34,79.3,68.167,158.7,102.5,238c34.3,79.3,51.8,119.3,52.5,120
49
+ c340,-704.7,510.7,-1060.3,512,-1067
50
+ l${extraViniculum / 2.084} -${extraViniculum}
51
+ c4.7,-7.3,11,-11,19,-11
52
+ H40000v${40 + extraViniculum}H1012.3
53
+ s-271.3,567,-271.3,567c-38.7,80.7,-84,175,-136,283c-52,108,-89.167,185.3,-111.5,232
54
+ c-22.3,46.7,-33.8,70.3,-34.5,71c-4.7,4.7,-12.3,7,-23,7s-12,-1,-12,-1
55
+ s-109,-253,-109,-253c-72.7,-168,-109.3,-252,-110,-252c-10.7,8,-22,16.7,-34,26
56
+ c-22,17.3,-33.3,26,-34,26s-26,-26,-26,-26s76,-59,76,-59s76,-60,76,-60z
57
+ M${1001 + extraViniculum} ${hLinePad}h400000v${40 + extraViniculum}h-400000z`;
58
+ };
30
59
 
60
+ const sqrtSize2 = function(extraViniculum: number, hLinePad: number): string {
31
61
  // size2 is from glyph U221A in the font KaTeX_Size2-Regular
32
- // The 80 units padding is most obvious here. Note start node at M1001 80.
33
- sqrtSize2: `M1001,${hLinePad}H400000v40H1013.1s-83.4,268,-264.1,840c-180.7,
34
- 572,-277,876.3,-289,913c-4.7,4.7,-12.7,7,-24,7s-12,0,-12,0c-1.3,-3.3,-3.7,-11.7,
35
- -7,-25c-35.3,-125.3,-106.7,-373.3,-214,-744c-10,12,-21,25,-33,39s-32,39,-32,39
36
- c-6,-5.3,-15,-14,-27,-26s25,-30,25,-30c26.7,-32.7,52,-63,76,-91s52,-60,52,-60
37
- s208,722,208,722c56,-175.3,126.3,-397.3,211,-666c84.7,-268.7,153.8,-488.2,207.5,
38
- -658.5c53.7,-170.3,84.5,-266.8,92.5,-289.5c4,-6.7,10,-10,18,-10z
39
- M1001 ${hLinePad}H400000v40H1013z`,
62
+ return `M983 ${10 + extraViniculum + hLinePad}
63
+ l${extraViniculum / 3.13} -${extraViniculum}
64
+ c4,-6.7,10,-10,18,-10 H400000v${40 + extraViniculum}
65
+ H1013.1s-83.4,268,-264.1,840c-180.7,572,-277,876.3,-289,913c-4.7,4.7,-12.7,7,-24,7
66
+ s-12,0,-12,0c-1.3,-3.3,-3.7,-11.7,-7,-25c-35.3,-125.3,-106.7,-373.3,-214,-744
67
+ c-10,12,-21,25,-33,39s-32,39,-32,39c-6,-5.3,-15,-14,-27,-26s25,-30,25,-30
68
+ c26.7,-32.7,52,-63,76,-91s52,-60,52,-60s208,722,208,722
69
+ c56,-175.3,126.3,-397.3,211,-666c84.7,-268.7,153.8,-488.2,207.5,-658.5
70
+ c53.7,-170.3,84.5,-266.8,92.5,-289.5z
71
+ M${1001 + extraViniculum} ${hLinePad}h400000v${40 + extraViniculum}h-400000z`;
72
+ };
40
73
 
74
+ const sqrtSize3 = function(extraViniculum: number, hLinePad: number): string {
41
75
  // size3 is from glyph U221A in the font KaTeX_Size3-Regular
42
- sqrtSize3: `M424,${2398 + hLinePad}c-1.3,-0.7,-38.5,-172,-111.5,-514c-73,
43
- -342,-109.8,-513.3,-110.5,-514c0,-2,-10.7,14.3,-32,49c-4.7,7.3,-9.8,15.7,-15.5,
44
- 25c-5.7,9.3,-9.8,16,-12.5,20s-5,7,-5,7c-4,-3.3,-8.3,-7.7,-13,-13s-13,-13,-13,
45
- -13s76,-122,76,-122s77,-121,77,-121s209,968,209,968c0,-2,84.7,-361.7,254,-1079
46
- c169.3,-717.3,254.7,-1077.7,256,-1081c4,-6.7,10,-10,18,-10H400000v40H1014.6
47
- s-87.3,378.7,-272.6,1166c-185.3,787.3,-279.3,1182.3,-282,1185c-2,6,-10,9,-24,9
48
- c-8,0,-12,-0.7,-12,-2z M1001 ${hLinePad}H400000v40H1014z`,
76
+ return `M424,${2398 + extraViniculum + hLinePad}
77
+ c-1.3,-0.7,-38.5,-172,-111.5,-514c-73,-342,-109.8,-513.3,-110.5,-514
78
+ c0,-2,-10.7,14.3,-32,49c-4.7,7.3,-9.8,15.7,-15.5,25c-5.7,9.3,-9.8,16,-12.5,20
79
+ s-5,7,-5,7c-4,-3.3,-8.3,-7.7,-13,-13s-13,-13,-13,-13s76,-122,76,-122s77,-121,77,-121
80
+ s209,968,209,968c0,-2,84.7,-361.7,254,-1079c169.3,-717.3,254.7,-1077.7,256,-1081
81
+ l${extraViniculum / 4.223} -${extraViniculum}c4,-6.7,10,-10,18,-10 H400000
82
+ v${40 + extraViniculum}H1014.6
83
+ s-87.3,378.7,-272.6,1166c-185.3,787.3,-279.3,1182.3,-282,1185
84
+ c-2,6,-10,9,-24,9
85
+ c-8,0,-12,-0.7,-12,-2z M${1001 + extraViniculum} ${hLinePad}
86
+ h400000v${40 + extraViniculum}h-400000z`;
87
+ };
49
88
 
89
+ const sqrtSize4 = function(extraViniculum: number, hLinePad: number): string {
50
90
  // size4 is from glyph U221A in the font KaTeX_Size4-Regular
51
- sqrtSize4: `M473,${2713 + hLinePad}c339.3,-1799.3,509.3,-2700,510,-2702
52
- c3.3,-7.3,9.3,-11,18,-11H400000v40H1017.7s-90.5,478,-276.2,1466c-185.7,988,
53
- -279.5,1483,-281.5,1485c-2,6,-10,9,-24,9c-8,0,-12,-0.7,-12,-2c0,-1.3,-5.3,-32,
54
- -16,-92c-50.7,-293.3,-119.7,-693.3,-207,-1200c0,-1.3,-5.3,8.7,-16,30c-10.7,
55
- 21.3,-21.3,42.7,-32,64s-16,33,-16,33s-26,-26,-26,-26s76,-153,76,-153s77,-151,
56
- 77,-151c0.7,0.7,35.7,202,105,604c67.3,400.7,102,602.7,104,606z
57
- M1001 ${hLinePad}H400000v40H1017z`,
91
+ return `M473,${2713 + extraViniculum + hLinePad}
92
+ c339.3,-1799.3,509.3,-2700,510,-2702 l${extraViniculum / 5.298} -${extraViniculum}
93
+ c3.3,-7.3,9.3,-11,18,-11 H400000v${40 + extraViniculum}H1017.7
94
+ s-90.5,478,-276.2,1466c-185.7,988,-279.5,1483,-281.5,1485c-2,6,-10,9,-24,9
95
+ c-8,0,-12,-0.7,-12,-2c0,-1.3,-5.3,-32,-16,-92c-50.7,-293.3,-119.7,-693.3,-207,-1200
96
+ c0,-1.3,-5.3,8.7,-16,30c-10.7,21.3,-21.3,42.7,-32,64s-16,33,-16,33s-26,-26,-26,-26
97
+ s76,-153,76,-153s77,-151,77,-151c0.7,0.7,35.7,202,105,604c67.3,400.7,102,602.7,104,
98
+ 606zM${1001 + extraViniculum} ${hLinePad}h400000v${40 + extraViniculum}H1017.7z`;
99
+ };
100
+
101
+ const sqrtTall = function(
102
+ extraViniculum: number,
103
+ hLinePad: number,
104
+ viewBoxHeight: number
105
+ ): string {
106
+ // sqrtTall is from glyph U23B7 in the font KaTeX_Size4-Regular
107
+ // One path edge has a variable length. It runs vertically from the viniculumn
108
+ // to a point near (14 units) the bottom of the surd. The viniculum
109
+ // is normally 40 units thick. So the length of the line in question is:
110
+ const vertSegment = viewBoxHeight - 54 - hLinePad - extraViniculum;
111
+
112
+ return `M702 ${extraViniculum + hLinePad}H400000${40 + extraViniculum}
113
+ H742v${vertSegment}l-4 4-4 4c-.667.7 -2 1.5-4 2.5s-4.167 1.833-6.5 2.5-5.5 1-9.5 1
114
+ h-12l-28-84c-16.667-52-96.667 -294.333-240-727l-212 -643 -85 170
115
+ c-4-3.333-8.333-7.667-13 -13l-13-13l77-155 77-156c66 199.333 139 419.667
116
+ 219 661 l218 661zM702 ${hLinePad}H400000v${40 + extraViniculum}H742z`;
117
+ };
118
+
119
+ export const sqrtPath = function(
120
+ size: string,
121
+ extraViniculum: number,
122
+ viewBoxHeight: number
123
+ ): string {
124
+ extraViniculum = 1000 * extraViniculum; // Convert from document ems to viewBox.
125
+ let path = "";
126
+
127
+ switch (size) {
128
+ case "sqrtMain":
129
+ path = sqrtMain(extraViniculum, hLinePad);
130
+ break;
131
+ case "sqrtSize1":
132
+ path = sqrtSize1(extraViniculum, hLinePad);
133
+ break;
134
+ case "sqrtSize2":
135
+ path = sqrtSize2(extraViniculum, hLinePad);
136
+ break;
137
+ case "sqrtSize3":
138
+ path = sqrtSize3(extraViniculum, hLinePad);
139
+ break;
140
+ case "sqrtSize4":
141
+ path = sqrtSize4(extraViniculum, hLinePad);
142
+ break;
143
+ case "sqrtTall":
144
+ path = sqrtTall(extraViniculum, hLinePad, viewBoxHeight);
145
+ }
146
+ return path;
147
+ };
148
+
149
+ export const path: {[string]: string} = {
150
+ // Two paths that cover gaps in built-up parentheses.
151
+ leftParenInner: `M291 0 H417 V300 H291 z`,
152
+ rightParenInner: `M457 0 H583 V300 H457 z`,
58
153
 
59
154
  // The doubleleftarrow geometry is from glyph U+21D0 in the font KaTeX Main
60
155
  doubleleftarrow: `M262 157
@@ -363,6 +458,3 @@ c4.7,-4.7,7,-9.3,7,-14c0,-9.3,-3.7,-15.3,-11,-18c-92.7,-56.7,-159,-133.7,-199,
363
458
  c-2,2.7,-1,9.7,3,21c15.3,42,36.7,81.8,64,119.5c27.3,37.7,58,69.2,92,94.5z
364
459
  M500 241 v40 H399408 v-40z M500 435 v40 H400000 v-40z`,
365
460
  };
366
-
367
-
368
- export default {path};