temml 0.11.6 → 0.11.7

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/dist/temml.mjs CHANGED
@@ -8992,88 +8992,6 @@ defineFunction({
8992
8992
  mathmlBuilder: mathmlBuilder$4
8993
8993
  });
8994
8994
 
8995
- defineFunction({
8996
- type: "href",
8997
- names: ["\\href"],
8998
- props: {
8999
- numArgs: 2,
9000
- argTypes: ["url", "original"],
9001
- allowedInText: true
9002
- },
9003
- handler: ({ parser, token }, args) => {
9004
- const body = args[1];
9005
- const href = assertNodeType(args[0], "url").url;
9006
-
9007
- if (
9008
- !parser.settings.isTrusted({
9009
- command: "\\href",
9010
- url: href
9011
- })
9012
- ) {
9013
- throw new ParseError(`Function "\\href" is not trusted`, token)
9014
- }
9015
-
9016
- return {
9017
- type: "href",
9018
- mode: parser.mode,
9019
- href,
9020
- body: ordargument(body)
9021
- };
9022
- },
9023
- mathmlBuilder: (group, style) => {
9024
- const math = new MathNode("math", [buildExpressionRow(group.body, style)]);
9025
- const anchorNode = new AnchorNode(group.href, [], [math]);
9026
- return anchorNode
9027
- }
9028
- });
9029
-
9030
- defineFunction({
9031
- type: "href",
9032
- names: ["\\url"],
9033
- props: {
9034
- numArgs: 1,
9035
- argTypes: ["url"],
9036
- allowedInText: true
9037
- },
9038
- handler: ({ parser, token }, args) => {
9039
- const href = assertNodeType(args[0], "url").url;
9040
-
9041
- if (
9042
- !parser.settings.isTrusted({
9043
- command: "\\url",
9044
- url: href
9045
- })
9046
- ) {
9047
- throw new ParseError(`Function "\\url" is not trusted`, token)
9048
- }
9049
-
9050
- const chars = [];
9051
- for (let i = 0; i < href.length; i++) {
9052
- let c = href[i];
9053
- if (c === "~") {
9054
- c = "\\textasciitilde";
9055
- }
9056
- chars.push({
9057
- type: "textord",
9058
- mode: "text",
9059
- text: c
9060
- });
9061
- }
9062
- const body = {
9063
- type: "text",
9064
- mode: parser.mode,
9065
- font: "\\texttt",
9066
- body: chars
9067
- };
9068
- return {
9069
- type: "href",
9070
- mode: parser.mode,
9071
- href,
9072
- body: ordargument(body)
9073
- };
9074
- }
9075
- });
9076
-
9077
8995
  defineFunction({
9078
8996
  type: "html",
9079
8997
  names: ["\\class", "\\id", "\\style", "\\data"],
@@ -9331,17 +9249,24 @@ defineFunction({
9331
9249
  },
9332
9250
  mathmlBuilder(group, style) {
9333
9251
  const dimension = calculateSize(group.dimension, style);
9334
- const ch = dimension.unit === "em" ? spaceCharacter(dimension.number) : "";
9252
+ const ch = dimension.number > 0 && dimension.unit === "em"
9253
+ ? spaceCharacter(dimension.number)
9254
+ : "";
9335
9255
  if (group.mode === "text" && ch.length > 0) {
9336
9256
  const character = new mathMLTree.TextNode(ch);
9337
9257
  return new mathMLTree.MathNode("mtext", [character]);
9338
9258
  } else {
9339
- const node = new mathMLTree.MathNode("mspace");
9340
- node.setAttribute("width", dimension.number + dimension.unit);
9341
- if (dimension.number < 0) {
9259
+ if (dimension.number >= 0) {
9260
+ const node = new mathMLTree.MathNode("mspace");
9261
+ node.setAttribute("width", dimension.number + dimension.unit);
9262
+ return node
9263
+ } else {
9264
+ // Don't use <mspace> or <mpadded> because
9265
+ // WebKit recognizes negative left margin only on a <mrow> element
9266
+ const node = new mathMLTree.MathNode("mrow");
9342
9267
  node.style.marginLeft = dimension.number + dimension.unit;
9268
+ return node
9343
9269
  }
9344
- return node;
9345
9270
  }
9346
9271
  }
9347
9272
  });
@@ -13972,7 +13897,7 @@ class Style {
13972
13897
  * https://mit-license.org/
13973
13898
  */
13974
13899
 
13975
- const version = "0.11.06";
13900
+ const version = "0.11.07";
13976
13901
 
13977
13902
  function postProcess(block) {
13978
13903
  const labelMap = {};
@@ -11,7 +11,7 @@
11
11
  * https://mit-license.org/
12
12
  */
13
13
 
14
- const version = "0.11.06";
14
+ const version = "0.11.07";
15
15
 
16
16
  function postProcess(block) {
17
17
  const labelMap = {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "temml",
3
- "version": "0.11.06",
3
+ "version": "0.11.07",
4
4
  "description": "TeX to MathML conversion in JavaScript.",
5
5
  "main": "dist/temml.js",
6
6
  "engines": {
@@ -45,17 +45,24 @@ defineFunction({
45
45
  },
46
46
  mathmlBuilder(group, style) {
47
47
  const dimension = calculateSize(group.dimension, style);
48
- const ch = dimension.unit === "em" ? spaceCharacter(dimension.number) : "";
48
+ const ch = dimension.number > 0 && dimension.unit === "em"
49
+ ? spaceCharacter(dimension.number)
50
+ : "";
49
51
  if (group.mode === "text" && ch.length > 0) {
50
52
  const character = new mathMLTree.TextNode(ch);
51
53
  return new mathMLTree.MathNode("mtext", [character]);
52
54
  } else {
53
- const node = new mathMLTree.MathNode("mspace");
54
- node.setAttribute("width", dimension.number + dimension.unit);
55
- if (dimension.number < 0) {
55
+ if (dimension.number >= 0) {
56
+ const node = new mathMLTree.MathNode("mspace")
57
+ node.setAttribute("width", dimension.number + dimension.unit)
58
+ return node
59
+ } else {
60
+ // Don't use <mspace> or <mpadded> because
61
+ // WebKit recognizes negative left margin only on a <mrow> element
62
+ const node = new mathMLTree.MathNode("mrow")
56
63
  node.style.marginLeft = dimension.number + dimension.unit
64
+ return node
57
65
  }
58
- return node;
59
66
  }
60
67
  }
61
68
  });
package/src/functions.js CHANGED
@@ -24,7 +24,6 @@ import "./functions/font";
24
24
  import "./functions/genfrac";
25
25
  import "./functions/hbox";
26
26
  import "./functions/horizBrace";
27
- import "./functions/href";
28
27
  import "./functions/html";
29
28
  import "./functions/includegraphics";
30
29
  import "./functions/kern";
@@ -5,7 +5,7 @@
5
5
  * https://mit-license.org/
6
6
  */
7
7
 
8
- export const version = "0.11.06";
8
+ export const version = "0.11.07";
9
9
 
10
10
  export function postProcess(block) {
11
11
  const labelMap = {}
@@ -1,88 +0,0 @@
1
- import defineFunction, { ordargument } from "../defineFunction";
2
- import { assertNodeType } from "../parseNode";
3
- import { MathNode } from "../mathMLTree";
4
- import { AnchorNode } from "../domTree";
5
- import * as mml from "../buildMathML";
6
- import ParseError from "../ParseError";
7
-
8
- defineFunction({
9
- type: "href",
10
- names: ["\\href"],
11
- props: {
12
- numArgs: 2,
13
- argTypes: ["url", "original"],
14
- allowedInText: true
15
- },
16
- handler: ({ parser, token }, args) => {
17
- const body = args[1];
18
- const href = assertNodeType(args[0], "url").url;
19
-
20
- if (
21
- !parser.settings.isTrusted({
22
- command: "\\href",
23
- url: href
24
- })
25
- ) {
26
- throw new ParseError(`Function "\\href" is not trusted`, token)
27
- }
28
-
29
- return {
30
- type: "href",
31
- mode: parser.mode,
32
- href,
33
- body: ordargument(body)
34
- };
35
- },
36
- mathmlBuilder: (group, style) => {
37
- const math = new MathNode("math", [mml.buildExpressionRow(group.body, style)])
38
- const anchorNode = new AnchorNode(group.href, [], [math])
39
- return anchorNode
40
- }
41
- });
42
-
43
- defineFunction({
44
- type: "href",
45
- names: ["\\url"],
46
- props: {
47
- numArgs: 1,
48
- argTypes: ["url"],
49
- allowedInText: true
50
- },
51
- handler: ({ parser, token }, args) => {
52
- const href = assertNodeType(args[0], "url").url;
53
-
54
- if (
55
- !parser.settings.isTrusted({
56
- command: "\\url",
57
- url: href
58
- })
59
- ) {
60
- throw new ParseError(`Function "\\url" is not trusted`, token)
61
- }
62
-
63
- const chars = [];
64
- for (let i = 0; i < href.length; i++) {
65
- let c = href[i];
66
- if (c === "~") {
67
- c = "\\textasciitilde";
68
- }
69
- chars.push({
70
- type: "textord",
71
- mode: "text",
72
- text: c
73
- });
74
- }
75
- const body = {
76
- type: "text",
77
- mode: parser.mode,
78
- font: "\\texttt",
79
- body: chars
80
- };
81
- return {
82
- type: "href",
83
- mode: parser.mode,
84
- href,
85
- body: ordargument(body)
86
- };
87
- }
88
- });