temml 0.9.2 → 0.10.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -2,7 +2,7 @@
2
2
  import defineFunction, { ordargument } from "../defineFunction";
3
3
  import * as mathMLTree from "../mathMLTree";
4
4
  import * as mml from "../buildMathML";
5
- import { delimiters, delimiterSizes } from "./delimsizing"
5
+ import { isDelimiter } from "./delimsizing"
6
6
 
7
7
  // Some helpers
8
8
 
@@ -14,10 +14,6 @@ const noSuccessor = ["\\smallint"];
14
14
  // Math operators (e.g. \sin) need a space between these types and themselves:
15
15
  export const ordTypes = ["textord", "mathord", "ordgroup", "close", "leftright"];
16
16
 
17
- const dels = ["}", "\\left", "\\middle", "\\right"]
18
- const isDelimiter = str => str.length > 0 &&
19
- (delimiters.includes(str) || delimiterSizes[str] || dels.includes(str))
20
-
21
17
  // NOTE: Unlike most `builders`s, this one handles not only "op", but also
22
18
  // "supsub" since some of them (like \int) can affect super/subscripting.
23
19
 
@@ -3,15 +3,11 @@ import defineMacro from "../defineMacro";
3
3
  import mathMLTree from "../mathMLTree"
4
4
  import { spaceCharacter } from "./kern"
5
5
  import { ordTypes } from "./op"
6
- import { delimiters, delimiterSizes } from "./delimsizing"
6
+ import { isDelimiter } from "./delimsizing"
7
7
 
8
8
  import * as mml from "../buildMathML"
9
9
 
10
- const dels = ["}", "\\left", "\\middle", "\\right"]
11
- const isDelimiter = str => str.length > 0 &&
12
- (delimiters.includes(str) || delimiterSizes[str] || dels.includes(str))
13
-
14
- // NOTE: Unlike most builders, this one handles not only
10
+ // NOTE: Unlike most builders, this one handles not only
15
11
  // "operatorname", but also "supsub" since \operatorname* can
16
12
  // affect super/subscripting.
17
13
 
@@ -21,8 +17,12 @@ const mathmlBuilder = (group, style) => {
21
17
  // Is expression a string or has it something like a fraction?
22
18
  let isAllString = true; // default
23
19
  for (let i = 0; i < expression.length; i++) {
24
- const node = expression[i]
20
+ let node = expression[i]
25
21
  if (node instanceof mathMLTree.MathNode) {
22
+ if (node.type === "mrow" && node.children.length === 1 &&
23
+ node.children[0] instanceof mathMLTree.MathNode) {
24
+ node = node.children[0]
25
+ }
26
26
  switch (node.type) {
27
27
  case "mi":
28
28
  case "mn":
@@ -80,7 +80,9 @@ const mathmlBuilder = (group, style) => {
80
80
  let wrapper;
81
81
  if (isAllString) {
82
82
  wrapper = new mathMLTree.MathNode("mi", expression)
83
- wrapper.setAttribute("mathvariant", "normal")
83
+ if (expression[0].text.length === 1) {
84
+ wrapper.setAttribute("mathvariant", "normal")
85
+ }
84
86
  } else {
85
87
  wrapper = new mathMLTree.MathNode("mrow", expression)
86
88
  }
@@ -24,6 +24,7 @@ defineFunctionBuilders({
24
24
  let isOver
25
25
  let isSup
26
26
  let appendApplyFunction = false
27
+ let appendSpace = false
27
28
  let needsLeadingSpace = false
28
29
 
29
30
  if (group.base && group.base.type === "horizBrace") {
@@ -38,6 +39,7 @@ defineFunctionBuilders({
38
39
  (group.base.type === "op" || group.base.type === "operatorname")) {
39
40
  group.base.parentIsSupSub = true
40
41
  appendApplyFunction = !group.base.symbol
42
+ appendSpace = appendApplyFunction && !group.isFollowedByDelimiter
41
43
  needsLeadingSpace = group.base.needsLeadingSpace
42
44
  }
43
45
 
@@ -125,6 +127,11 @@ defineFunctionBuilders({
125
127
  } else {
126
128
  node = mathMLTree.newDocumentFragment([node, operator])
127
129
  }
130
+ if (appendSpace) {
131
+ const space = new mathMLTree.MathNode("mspace")
132
+ space.setAttribute("width", "0.1667em") // thin space.
133
+ node.children.push(space)
134
+ }
128
135
  } else if (symbolRegEx.test(nodeType)) {
129
136
  // Wrap in a <mrow>. Otherwise Firefox stretchy parens will not stretch to include limits.
130
137
  node = new mathMLTree.MathNode("mrow", [node])
@@ -63,10 +63,7 @@ defineFunctionBuilders({
63
63
  let node
64
64
  if (numberRegEx.test(group.text)) {
65
65
  const tag = group.mode === "text" ? "mtext" : "mn"
66
- if (variant === "oldstylenums") {
67
- const ms = new mathMLTree.MathNode("mstyle", [text], ["oldstylenums"])
68
- node = new mathMLTree.MathNode(tag, [ms])
69
- } else if (variant === "italic" || variant === "bold-italic") {
66
+ if (variant === "italic" || variant === "bold-italic") {
70
67
  return italicNumber(text, variant, tag)
71
68
  } else {
72
69
  if (variant !== "normal") {
package/src/mathMLTree.js CHANGED
@@ -148,7 +148,7 @@ export class TextNode {
148
148
 
149
149
  /**
150
150
  * Converts the text node into a string
151
- * (representing the text iteself).
151
+ * (representing the text itself).
152
152
  */
153
153
  toText() {
154
154
  return this.text;
@@ -8,7 +8,7 @@
8
8
  * https://mit-license.org/
9
9
  */
10
10
 
11
- export const version = "0.9.2";
11
+ export const version = "0.10.2";
12
12
 
13
13
  export function postProcess(block) {
14
14
  const labelMap = {}
package/src/symbols.js CHANGED
@@ -85,7 +85,6 @@ defineSymbol(math, rel, "\u226a", "\\ll", true);
85
85
  defineSymbol(math, rel, "\u226b", "\\gg", true);
86
86
  defineSymbol(math, rel, "\u224d", "\\asymp", true);
87
87
  defineSymbol(math, rel, "\u2225", "\\parallel");
88
- defineSymbol(math, rel, "\u22c8", "\\bowtie", true);
89
88
  defineSymbol(math, rel, "\u2323", "\\smile", true);
90
89
  defineSymbol(math, rel, "\u2291", "\\sqsubseteq", true);
91
90
  defineSymbol(math, rel, "\u2292", "\\sqsupseteq", true);
@@ -402,7 +401,6 @@ defineSymbol(math, rel, "\u22d9", "\\gggtr");
402
401
  defineSymbol(math, bin, "\u22b2", "\\lhd");
403
402
  defineSymbol(math, bin, "\u22b3", "\\rhd");
404
403
  defineSymbol(math, rel, "\u2242", "\\eqsim", true);
405
- defineSymbol(math, rel, "\u22c8", "\\Join");
406
404
  defineSymbol(math, rel, "\u2251", "\\Doteq", true);
407
405
  defineSymbol(math, rel, "\u297d", "\\strictif", true);
408
406
  defineSymbol(math, rel, "\u297c", "\\strictfi", true);
@@ -428,6 +426,11 @@ defineSymbol(math, bin, "\u22ba", "\\intercal", true);
428
426
  defineSymbol(math, bin, "\u22d2", "\\doublecap");
429
427
  defineSymbol(math, bin, "\u22d3", "\\doublecup");
430
428
  defineSymbol(math, bin, "\u22a0", "\\boxtimes", true);
429
+ defineSymbol(math, bin, "\u22c8", "\\bowtie", true);
430
+ defineSymbol(math, bin, "\u22c8", "\\Join");
431
+ defineSymbol(math, bin, "\u27d5", "\\leftouterjoin", true);
432
+ defineSymbol(math, bin, "\u27d6", "\\rightouterjoin", true);
433
+ defineSymbol(math, bin, "\u27d7", "\\fullouterjoin", true);
431
434
 
432
435
  // AMS Arrows
433
436
  // Note: unicode-math maps \u21e2 to their own function \rightdasharrow.
@@ -474,6 +477,8 @@ defineSymbol(math, textord, "\u2018", "`");
474
477
  defineSymbol(math, textord, "$", "\\$");
475
478
  defineSymbol(text, textord, "$", "\\$");
476
479
  defineSymbol(text, textord, "$", "\\textdollar");
480
+ defineSymbol(math, textord, "¢", "\\cent");
481
+ defineSymbol(text, textord, "¢", "\\cent");
477
482
  defineSymbol(math, textord, "%", "\\%");
478
483
  defineSymbol(text, textord, "%", "\\%");
479
484
  defineSymbol(math, textord, "_", "\\_");
package/src/variant.js CHANGED
@@ -17,8 +17,7 @@ const fontMap = {
17
17
  mathfrak: "fraktur",
18
18
  mathscr: "script",
19
19
  mathsf: "sans-serif",
20
- mathtt: "monospace",
21
- oldstylenums: "oldstylenums"
20
+ mathtt: "monospace"
22
21
  }
23
22
 
24
23
  /**
@@ -88,8 +87,6 @@ export const getVariant = function(group, style) {
88
87
  return "sans-serif"
89
88
  case "mathtt":
90
89
  return "monospace"
91
- case "oldstylenums":
92
- return "oldstylenums"
93
90
  default:
94
91
  break
95
92
  }