temml 0.10.32 → 0.10.33

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.
@@ -1,37 +1,45 @@
1
1
  /* Temml Post Process
2
- * Perform two tasks not done by Temml when it created each individual Temml <math> element.
3
- * Given a block,
4
- * 1. At each AMS auto-numbered environment, assign an id.
5
- * 2. Populate the text contents of each \ref & \eqref
2
+ * Populate the text contents of each \ref & \eqref
6
3
  *
7
4
  * As with other Temml code, this file is released under terms of the MIT license.
8
5
  * https://mit-license.org/
9
6
  */
10
7
 
11
- export const version = "0.10.32";
8
+ export const version = "0.10.33";
12
9
 
13
10
  export function postProcess(block) {
14
11
  const labelMap = {}
15
12
  let i = 0
16
13
 
17
14
  // Get a collection of the parents of each \tag & auto-numbered equation
18
- const parents = block.getElementsByClassName("tml-tageqn");
19
- for (const parent of parents) {
20
- const eqns = parent.getElementsByClassName("tml-eqn")
21
- if (eqns. length > 0 ) {
22
- // AMS automatically numbered equation.
23
- // Assign an id.
24
- i += 1;
25
- eqns[0].id = "tml-eqn-" + i
26
- // No need to write a number into the text content of the element.
27
- // A CSS counter does that even if this postProcess() function is not used.
15
+ const amsEqns = document.getElementsByClassName('tml-eqn')
16
+ for (let parent of amsEqns) {
17
+ // AMS automatically numbered equation.
18
+ // Assign an id.
19
+ i += 1;
20
+ parent.setAttribute("id", "tml-eqn-" + String(i))
21
+ // No need to write a number into the text content of the element.
22
+ // A CSS counter has done that even if this postProcess() function is not used.
23
+
24
+ // Find any \label that refers to an AMS eqn number.
25
+ while (true) {
26
+ const labels = parent.getElementsByClassName("tml-label")
27
+ if (labels.length > 0) {
28
+ parent.setAttribute("id", labels[0].id)
29
+ labelMap[labels[0].id] = String(i)
30
+ break
31
+ } else {
32
+ if (parent.tagName === "mtable") { break }
33
+ parent = parent.parentElement
34
+ }
28
35
  }
29
- // If there is a \label, add it to labelMap
36
+ }
37
+
38
+ // Find \labels associated with \tag
39
+ const taggedEqns = document.getElementsByClassName('tml-tageqn')
40
+ for (const parent of taggedEqns) {
30
41
  const labels = parent.getElementsByClassName("tml-label")
31
- if (labels.length === 0) { continue }
32
- if (eqns.length > 0) {
33
- labelMap[labels[0].id] = String(i)
34
- } else {
42
+ if (labels.length > 0) {
35
43
  const tags = parent.getElementsByClassName("tml-tag")
36
44
  if (tags.length > 0) {
37
45
  labelMap[labels[0].id] = tags[0].textContent
@@ -42,16 +50,21 @@ export function postProcess(block) {
42
50
  // Populate \ref & \eqref text content
43
51
  const refs = block.getElementsByClassName("tml-ref");
44
52
  [...refs].forEach(ref => {
45
- let str = labelMap[ref.getAttribute("href").slice(1)];
53
+ const attr = ref.getAttribute("href")
54
+ let str = labelMap[attr.slice(1)];
46
55
  if (ref.className.indexOf("tml-eqref") === -1) {
47
56
  // \ref. Omit parens.
48
57
  str = str.replace(/^\(/, "")
49
- str = str.replace(/\($/, "")
50
- } {
58
+ str = str.replace(/\)$/, "")
59
+ } else {
51
60
  // \eqref. Include parens
52
61
  if (str.charAt(0) !== "(") { str = "(" + str }
53
62
  if (str.slice(-1) !== ")") { str = str + ")" }
54
63
  }
55
- ref.textContent = str
64
+ const mtext = document.createElementNS("http://www.w3.org/1998/Math/MathML", "mtext")
65
+ mtext.appendChild(document.createTextNode(str))
66
+ const math = document.createElementNS("http://www.w3.org/1998/Math/MathML", "math")
67
+ math.appendChild(mtext)
68
+ ref.appendChild(math)
56
69
  })
57
70
  }
package/src/symbols.js CHANGED
@@ -692,7 +692,7 @@ defineSymbol(math, open, "\u27e8", "\\langle", true);
692
692
  defineSymbol(math, open, "\u27ea", "\\lAngle", true);
693
693
  defineSymbol(math, open, "\u2989", "\\llangle", true);
694
694
  defineSymbol(math, open, "|", "\\lvert");
695
- defineSymbol(math, open, "\u2016", "\\lVert");
695
+ defineSymbol(math, open, "\u2016", "\\lVert", true);
696
696
  defineSymbol(math, textord, "!", "\\oc"); // cmll package
697
697
  defineSymbol(math, textord, "?", "\\wn");
698
698
  defineSymbol(math, textord, "\u2193", "\\shpos");
@@ -856,7 +856,7 @@ defineSymbol(math, inner, "\u22f0", "\\iddots", true);
856
856
  defineSymbol(math, inner, "\u22ef", "\\@cdots", true);
857
857
  defineSymbol(math, inner, "\u22f1", "\\ddots", true);
858
858
  defineSymbol(math, textord, "\u22ee", "\\varvdots"); // \vdots is a macro
859
- defineSymbol(text, textord, "\u22ee", "\\textvdots");
859
+ defineSymbol(text, textord, "\u22ee", "\\varvdots");
860
860
  defineSymbol(math, accent, "\u02ca", "\\acute");
861
861
  defineSymbol(math, accent, "\u0060", "\\grave");
862
862
  defineSymbol(math, accent, "\u00a8", "\\ddot");
package/src/variant.js CHANGED
@@ -85,6 +85,8 @@ export const getVariant = function(group, style) {
85
85
  return "script"
86
86
  case "mathsf":
87
87
  return "sans-serif"
88
+ case "mathsfit":
89
+ return "sans-serif-italic"
88
90
  case "mathtt":
89
91
  return "monospace"
90
92
  default: