temml 0.10.16 → 0.10.17

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.
@@ -14,7 +14,7 @@
14
14
  * https://mit-license.org/
15
15
  */
16
16
 
17
- const version = "0.10.16";
17
+ const version = "0.10.17";
18
18
 
19
19
  function postProcess(block) {
20
20
  const labelMap = {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "temml",
3
- "version": "0.10.16",
3
+ "version": "0.10.17",
4
4
  "description": "TeX to MathML conversion in JavaScript.",
5
5
  "main": "dist/temml.js",
6
6
  "engines": {
@@ -207,13 +207,8 @@ const taggedExpression = (expression, tag, style, leqno) => {
207
207
 
208
208
  expression = new mathMLTree.MathNode("mtd", [expression])
209
209
  const rowArray = [glue(), expression, glue()]
210
- if (leqno) {
211
- rowArray[0].children.push(tag)
212
- rowArray[0].style.textAlign = "-webkit-left"
213
- } else {
214
- rowArray[2].children.push(tag)
215
- rowArray[2].style.textAlign = "-webkit-right"
216
- }
210
+ rowArray[leqno ? 0 : 2].classes.push(leqno ? "tml-left" : "tml-right")
211
+ rowArray[leqno ? 0 : 2].children.push(tag)
217
212
  const mtr = new mathMLTree.MathNode("mtr", rowArray, ["tml-tageqn"])
218
213
  const table = new mathMLTree.MathNode("mtable", [mtr])
219
214
  table.style.width = "100%"
@@ -2,6 +2,7 @@ import defineEnvironment from "../defineEnvironment";
2
2
  import { parseCD } from "./cd";
3
3
  import defineFunction from "../defineFunction";
4
4
  import mathMLTree from "../mathMLTree";
5
+ import { Span } from "../domTree"
5
6
  import { StyleLevel } from "../constants"
6
7
  import ParseError from "../ParseError";
7
8
  import { assertNodeType, assertSymbolNodeType } from "../parseNode";
@@ -57,8 +58,9 @@ const getTag = (group, style, rowNum) => {
57
58
  return tag
58
59
  } else {
59
60
  // AMS automatcally numbered equaton.
60
- // Insert a class so the element can be populated by a post-processor.
61
- tag = new mathMLTree.MathNode("mtext", [], ["tml-eqn"])
61
+ // Insert a class so the element can be populated by a CSS counter.
62
+ // WebKit will display the CSS counter only inside a span.
63
+ tag = new mathMLTree.MathNode("mtext", [new Span(["tml-eqn"])])
62
64
  }
63
65
  return tag
64
66
  }
@@ -255,7 +257,7 @@ const mathmlBuilder = function(group, style) {
255
257
  const align = i === 0 ? "left" : i === numRows - 1 ? "right" : "center"
256
258
  mtd.setAttribute("columnalign", align)
257
259
  if (align !== "center") {
258
- mtd.style.textAlign = "-webkit-" + align
260
+ mtd.classes.push("tml-" + align)
259
261
  }
260
262
  }
261
263
  row.push(mtd)
@@ -266,10 +268,10 @@ const mathmlBuilder = function(group, style) {
266
268
  const tag = getTag(group, style.withLevel(cellLevel), i)
267
269
  if (group.leqno) {
268
270
  row[0].children.push(tag)
269
- row[0].style.textAlign = "-webkit-left"
271
+ row[0].classes.push("tml-left")
270
272
  } else {
271
273
  row[row.length - 1].children.push(tag)
272
- row[row.length - 1].style.textAlign = "-webkit-right"
274
+ row[row.length - 1].classes.push("tml-right")
273
275
  }
274
276
  }
275
277
  const mtr = new mathMLTree.MathNode("mtr", row, [])
@@ -340,11 +342,11 @@ const mathmlBuilder = function(group, style) {
340
342
  for (let j = 0; j < row.children.length; j++) {
341
343
  // Chromium does not recognize text-align: left. Use -webkit-
342
344
  // TODO: Remove -webkit- when Chromium no longer needs it.
343
- row.children[j].style.textAlign = "-webkit-" + (j % 2 ? "left" : "right")
345
+ row.children[j].classes = ["tml-" + (j % 2 ? "left" : "right")]
344
346
  }
345
347
  if (group.addEqnNum) {
346
348
  const k = group.leqno ? 0 : row.children.length - 1
347
- row.children[k].style.textAlign = "-webkit-" + (group.leqno ? "left" : "right")
349
+ row.children[k].classes = ["tml-" + (group.leqno ? "left" : "right")]
348
350
  }
349
351
  }
350
352
  if (row.children.length > 1 && group.envClasses.includes("cases")) {
@@ -353,7 +355,7 @@ const mathmlBuilder = function(group, style) {
353
355
 
354
356
  if (group.envClasses.includes("cases") || group.envClasses.includes("subarray")) {
355
357
  for (const cell of row.children) {
356
- cell.style.textAlign = "-webkit-" + "left"
358
+ cell.classes.push("tml-left")
357
359
  }
358
360
  }
359
361
  }
@@ -408,7 +410,7 @@ const mathmlBuilder = function(group, style) {
408
410
  iCol += 1
409
411
  for (const row of table.children) {
410
412
  if (colAlign.trim() !== "center" && iCol < row.children.length) {
411
- row.children[iCol].style.textAlign = "-webkit-" + colAlign.trim()
413
+ row.children[iCol].classes = ["tml-" + colAlign.trim()]
412
414
  }
413
415
  }
414
416
  prevTypeWasAlign = true;
@@ -2,6 +2,16 @@ import defineFunction, { normalizeArgument } from "../defineFunction"
2
2
  import mathMLTree from "../mathMLTree"
3
3
  import stretchy from "../stretchy"
4
4
  import * as mml from "../buildMathML"
5
+ import utils from "../utils"
6
+
7
+ const smalls = "acegıȷmnopqrsuvwxyzαγεηικμνοπρςστυχωϕ𝐚𝐜𝐞𝐠𝐦𝐧𝐨𝐩𝐪𝐫𝐬𝐮𝐯𝐰𝐱𝐲𝐳"
8
+ const talls = "ABCDEFGHIJKLMNOPQRSTUVWXYZbdfhkltΑΒΓΔΕΖΗΘΙΚΛΜΝΞΟΠΡΣΤΥΦΧΨΩβδλζφθψ"
9
+ + "𝐀𝐁𝐂𝐃𝐄𝐅𝐆𝐇𝐈𝐉𝐊𝐋𝐌𝐍𝐎𝐏𝐐𝐑𝐒𝐓𝐔𝐕𝐖𝐗𝐘𝐙𝐛𝐝𝐟𝐡𝐤𝐥𝐭"
10
+ const longSmalls = new Set(["\\alpha", "\\gamma", "\\delta", "\\epsilon", "\\eta", "\\iota",
11
+ "\\kappa", "\\mu", "\\nu", "\\pi", "\\rho", "\\sigma", "\\tau", "\\upsilon", "\\chi", "\\psi",
12
+ "\\omega", "\\imath", "\\jmath"])
13
+ const longTalls = new Set(["\\Gamma", "\\Delta", "\\Sigma", "\\Omega", "\\beta", "\\delta",
14
+ "\\lambda", "\\theta", "\\psi"])
5
15
 
6
16
  const mathmlBuilder = (group, style) => {
7
17
  const accentNode = group.isStretchy
@@ -13,6 +23,13 @@ const mathmlBuilder = (group, style) => {
13
23
  } else {
14
24
  accentNode.style.mathStyle = "normal"
15
25
  accentNode.style.mathDepth = "0"
26
+ if (needWebkitShift.has(group.label) && utils.isCharacterBox(group.base)) {
27
+ let shift = ""
28
+ const ch = group.base.text
29
+ if (smalls.indexOf(ch) > -1 || longSmalls.has(ch)) { shift = "tml-xshift" }
30
+ if (talls.indexOf(ch) > -1 || longTalls.has(ch)) { shift = "tml-capshift" }
31
+ if (shift) { accentNode.classes.push(shift) }
32
+ }
16
33
  }
17
34
  if (!group.isStretchy) {
18
35
  accentNode.setAttribute("stretchy", "false")
@@ -41,6 +58,19 @@ const nonStretchyAccents = new Set([
41
58
  "\\mathring"
42
59
  ])
43
60
 
61
+ const needWebkitShift = new Set([
62
+ "\\acute",
63
+ "\\bar",
64
+ "\\breve",
65
+ "\\check",
66
+ "\\dot",
67
+ "\\ddot",
68
+ "\\grave",
69
+ "\\hat",
70
+ "\\mathring",
71
+ "\\'", "\\^", "\\~", "\\=", "\\u", "\\.", '\\"', "\\r", "\\H", "\\v"
72
+ ])
73
+
44
74
  // Accents
45
75
  defineFunction({
46
76
  type: "accent",
@@ -63,7 +63,10 @@ rgba(0,0,0,0) 100%);`
63
63
  node.style.marginRight = "0.03889em"
64
64
  break
65
65
  case "\\sout":
66
- node.style["text-decoration"] = "line-through 0.08em solid"
66
+ node.style.backgroundImage = 'linear-gradient(black, black)'
67
+ node.style.backgroundRepeat = 'no-repeat'
68
+ node.style.backgroundSize = '100% 1.5px'
69
+ node.style.backgroundPosition = '0 center'
67
70
  break
68
71
  case "\\boxed":
69
72
  // \newcommand{\boxed}[1]{\fbox{\m@th$\displaystyle#1$}} from amsmath.sty
@@ -4,7 +4,7 @@ import mathMLTree from "../mathMLTree"
4
4
  import * as mml from "../buildMathML"
5
5
  import ParseError from "../ParseError";
6
6
 
7
- const textModeLap = ["\\clap", "\\llap", "\\rlap"]
7
+ const textModeLap = ["\\clap", "\\llap", "\\rlap"];
8
8
 
9
9
  defineFunction({
10
10
  type: "lap",
@@ -8,7 +8,7 @@
8
8
  * https://mit-license.org/
9
9
  */
10
10
 
11
- export const version = "0.10.16";
11
+ export const version = "0.10.17";
12
12
 
13
13
  export function postProcess(block) {
14
14
  const labelMap = {}
package/src/symbols.js CHANGED
@@ -913,8 +913,6 @@ for (let i = 0; i < letters.length; i++) {
913
913
  defineSymbol(math, mathord, ch, ch);
914
914
  defineSymbol(text, textord, ch, ch);
915
915
  }
916
- // Prevent Firefox from using a dotless i.
917
- defineSymbol(text, textord, "i\uFE0E", "i")
918
916
 
919
917
  // Some more letters in Unicode Basic Multilingual Plane.
920
918
  const narrow = "ÇÐÞçþℂℍℕℙℚℝℤℎℏℊℋℌℐℑℒℓ℘ℛℜℬℰℱℳℭℨ";