@pie-lib/math-rendering 2.3.10-next.306 → 2.3.10-next.414

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/CHANGELOG.md CHANGED
@@ -3,6 +3,82 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ ## [2.4.2](https://github.com/pie-framework/pie-lib/compare/@pie-lib/math-rendering@2.4.1...@pie-lib/math-rendering@2.4.2) (2022-05-30)
7
+
8
+
9
+ ### Bug Fixes
10
+
11
+ * unable to load items locally ([17ab686](https://github.com/pie-framework/pie-lib/commit/17ab6864557288aef6ec1d9a130cb508e2591562))
12
+
13
+
14
+
15
+
16
+
17
+ ## [2.4.1](https://github.com/pie-framework/pie-lib/compare/@pie-lib/math-rendering@2.4.0...@pie-lib/math-rendering@2.4.1) (2022-05-24)
18
+
19
+
20
+ ### Bug Fixes
21
+
22
+ * unable to load items locally ([a0ddf20](https://github.com/pie-framework/pie-lib/commit/a0ddf2095646e6e84569cb7e0de42d0cd9ea0fb6))
23
+
24
+
25
+
26
+
27
+
28
+ # [2.4.0](https://github.com/pie-framework/pie-lib/compare/@pie-lib/math-rendering@2.3.13...@pie-lib/math-rendering@2.4.0) (2022-04-28)
29
+
30
+
31
+ ### Bug Fixes
32
+
33
+ * tests ([90d79c4](https://github.com/pie-framework/pie-lib/commit/90d79c4b8c61c029959a729ba1eea1d69a3f2cbe))
34
+
35
+
36
+ ### Features
37
+
38
+ * add data-mathml attribute on MathJax containers to be able to use with Text to Speech (TTS) PD-1499 ([df50318](https://github.com/pie-framework/pie-lib/commit/df503184814f0463ef588e468570db3f7d2651df))
39
+
40
+
41
+
42
+
43
+
44
+ ## [2.3.13](https://github.com/pie-framework/pie-lib/compare/@pie-lib/math-rendering@2.3.12...@pie-lib/math-rendering@2.3.13) (2022-03-21)
45
+
46
+
47
+ ### Bug Fixes
48
+
49
+ * **math-rendering:** fix line spacing for mathjax mspace PD-1384 ([57fe827](https://github.com/pie-framework/pie-lib/commit/57fe827372c81138b35f294f16327c291872c8a2))
50
+
51
+
52
+
53
+
54
+
55
+ ## [2.3.12](https://github.com/pie-framework/pie-lib/compare/@pie-lib/math-rendering@2.3.11...@pie-lib/math-rendering@2.3.12) (2021-11-29)
56
+
57
+ **Note:** Version bump only for package @pie-lib/math-rendering
58
+
59
+
60
+
61
+
62
+
63
+ ## [2.3.11](https://github.com/pie-framework/pie-lib/compare/@pie-lib/math-rendering@2.3.10...@pie-lib/math-rendering@2.3.11) (2021-09-08)
64
+
65
+ **Note:** Version bump only for package @pie-lib/math-rendering
66
+
67
+
68
+
69
+
70
+
71
+ ## [2.3.10](https://github.com/pie-framework/pie-lib/compare/@pie-lib/math-rendering@2.3.9...@pie-lib/math-rendering@2.3.10) (2021-09-08)
72
+
73
+
74
+ ### Bug Fixes
75
+
76
+ * wip ([fe4316d](https://github.com/pie-framework/pie-lib/commit/fe4316d))
77
+
78
+
79
+
80
+
81
+
6
82
  ## [2.3.9](https://github.com/pie-framework/pie-lib/compare/@pie-lib/math-rendering@2.3.8...@pie-lib/math-rendering@2.3.9) (2021-08-30)
7
83
 
8
84
 
package/lib/index.js CHANGED
@@ -1,5 +1,7 @@
1
1
  "use strict";
2
2
 
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+
3
5
  Object.defineProperty(exports, "__esModule", {
4
6
  value: true
5
7
  });
@@ -25,6 +27,4 @@ Object.defineProperty(exports, "wrapMath", {
25
27
  var _renderMath = _interopRequireDefault(require("./render-math"));
26
28
 
27
29
  var _normalization = require("./normalization");
28
-
29
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
30
30
  //# sourceMappingURL=index.js.map
package/lib/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":[],"sources":["../src/index.js"],"sourcesContent":["import renderMath from './render-math';\nimport { wrapMath, unWrapMath } from './normalization';\n\nexport { renderMath, wrapMath, unWrapMath };\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAAA;;AACA"}
1
+ {"version":3,"file":"index.js","names":[],"sources":["../src/index.js"],"sourcesContent":["import renderMath from './render-math';\nimport { wrapMath, unWrapMath } from './normalization';\n\nexport { renderMath, wrapMath, unWrapMath };\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;AACA"}
@@ -1,49 +1,31 @@
1
1
  "use strict";
2
2
 
3
- function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
4
 
5
5
  Object.defineProperty(exports, "__esModule", {
6
6
  value: true
7
7
  });
8
8
  exports.getStackData = exports.Row = exports.Line = exports.CHTMLmstack = void 0;
9
9
 
10
- var _Wrapper = require("mathjax-full/js/output/chtml/Wrapper");
11
-
12
- var _lodash = _interopRequireDefault(require("lodash"));
13
-
14
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
15
-
16
- function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); }
17
-
18
- function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
19
-
20
- function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
21
-
22
- function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); }
23
-
24
- function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
25
-
26
- function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
27
-
28
- function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
10
+ var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
29
11
 
30
- function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
12
+ var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
31
13
 
32
- function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
14
+ var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
33
15
 
34
- function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
16
+ var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
35
17
 
36
- function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
18
+ var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
37
19
 
38
- function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
20
+ var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
39
21
 
40
- function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
22
+ var _Wrapper = require("mathjax-full/js/output/chtml/Wrapper");
41
23
 
42
- function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
24
+ var _lodash = _interopRequireDefault(require("lodash"));
43
25
 
44
- function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
26
+ function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2["default"])(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2["default"])(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2["default"])(this, result); }; }
45
27
 
46
- function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
28
+ function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
47
29
 
48
30
  var reduceText = function reduceText(acc, n) {
49
31
  if (n.node && n.node.kind === 'text') {
@@ -55,18 +37,16 @@ var reduceText = function reduceText(acc, n) {
55
37
 
56
38
  var Line = /*#__PURE__*/function () {
57
39
  function Line() {
58
- _classCallCheck(this, Line);
59
-
40
+ (0, _classCallCheck2["default"])(this, Line);
60
41
  this.kind = 'line';
61
42
  }
62
43
 
63
- _createClass(Line, [{
44
+ (0, _createClass2["default"])(Line, [{
64
45
  key: "columns",
65
46
  get: function get() {
66
47
  return [];
67
48
  }
68
49
  }]);
69
-
70
50
  return Line;
71
51
  }();
72
52
 
@@ -74,14 +54,13 @@ exports.Line = Line;
74
54
 
75
55
  var Row = /*#__PURE__*/function () {
76
56
  function Row(columns, operator) {
77
- _classCallCheck(this, Row);
78
-
57
+ (0, _classCallCheck2["default"])(this, Row);
79
58
  this.kind = 'row';
80
59
  this.operator = operator;
81
60
  this.columns = columns;
82
61
  }
83
62
 
84
- _createClass(Row, [{
63
+ (0, _createClass2["default"])(Row, [{
85
64
  key: "pad",
86
65
  value: function pad(count) {
87
66
  var direction = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'right';
@@ -96,10 +75,9 @@ var Row = /*#__PURE__*/function () {
96
75
  return '__pad__';
97
76
  });
98
77
 
99
- return direction === 'right' ? [].concat(_toConsumableArray(padding), _toConsumableArray(this.columns)) : [].concat(_toConsumableArray(this.columns), _toConsumableArray(padding));
78
+ return direction === 'right' ? [].concat((0, _toConsumableArray2["default"])(padding), (0, _toConsumableArray2["default"])(this.columns)) : [].concat((0, _toConsumableArray2["default"])(this.columns), (0, _toConsumableArray2["default"])(padding));
100
79
  }
101
80
  }]);
102
-
103
81
  return Row;
104
82
  }();
105
83
 
@@ -202,7 +180,7 @@ var getStackData = function getStackData(mstack) {
202
180
  exports.getStackData = getStackData;
203
181
 
204
182
  var CHTMLmstack = /*#__PURE__*/function (_CHTMLWrapper) {
205
- _inherits(CHTMLmstack, _CHTMLWrapper);
183
+ (0, _inherits2["default"])(CHTMLmstack, _CHTMLWrapper);
206
184
 
207
185
  var _super = _createSuper(CHTMLmstack);
208
186
 
@@ -210,15 +188,13 @@ var CHTMLmstack = /*#__PURE__*/function (_CHTMLWrapper) {
210
188
  var _this;
211
189
 
212
190
  var parent = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
213
-
214
- _classCallCheck(this, CHTMLmstack);
215
-
191
+ (0, _classCallCheck2["default"])(this, CHTMLmstack);
216
192
  _this = _super.call(this, factory, node, parent);
217
193
  _this.ce = _this.adaptor.document.createElement.bind(_this.adaptor.document);
218
194
  return _this;
219
195
  }
220
196
 
221
- _createClass(CHTMLmstack, [{
197
+ (0, _createClass2["default"])(CHTMLmstack, [{
222
198
  key: "toCHTML",
223
199
  value: function toCHTML(parent) {
224
200
  var _this2 = this;
@@ -284,7 +260,6 @@ var CHTMLmstack = /*#__PURE__*/function (_CHTMLWrapper) {
284
260
  });
285
261
  }
286
262
  }]);
287
-
288
263
  return CHTMLmstack;
289
264
  }(_Wrapper.CHTMLWrapper);
290
265
 
@@ -311,6 +286,9 @@ CHTMLmstack.styles = {
311
286
  'mjx-mstack > table > tr > .mjx-line': {
312
287
  padding: 0,
313
288
  'border-top': 'solid 1px black'
289
+ },
290
+ '.TEX-A': {
291
+ 'font-family': 'MJXZERO, MJXTEX !important'
314
292
  }
315
293
  };
316
294
  //# sourceMappingURL=chtml.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"chtml.js","names":["reduceText","acc","n","node","kind","text","Line","Row","columns","operator","count","direction","length","Error","diff","padding","_","times","map","mathNodeToCharArray","mn","childNodes","reduce","split","toColumnArray","child","console","warn","toCHTML","rowStack","f","first","nodes","tail","flatten","undefined","getStackData","mstack","compact","CHTMLmstack","factory","parent","ce","adaptor","document","createElement","bind","chtml","standardCHTMLnode","stackData","maxCols","r","table","appendChild","forEach","row","tr","td","setAttribute","textContent","cols","pad","c","t","CHTMLWrapper","styles","border"],"sources":["../../src/mstack/chtml.js"],"sourcesContent":["import { CHTMLWrapper } from 'mathjax-full/js/output/chtml/Wrapper';\nimport _ from 'lodash';\n\nconst reduceText = (acc, n) => {\n if (n.node && n.node.kind === 'text') {\n acc += n.node.text;\n }\n return acc;\n};\n\nexport class Line {\n constructor() {\n this.kind = 'line';\n }\n\n get columns() {\n return [];\n }\n}\n\nexport class Row {\n constructor(columns, operator) {\n this.kind = 'row';\n this.operator = operator;\n this.columns = columns;\n }\n\n pad(count, direction = 'right') {\n if (count < this.columns.length) {\n throw new Error('no');\n }\n\n const diff = count - this.columns.length;\n\n const padding = _.times(diff).map(n => '__pad__');\n return direction === 'right' ? [...padding, ...this.columns] : [...this.columns, ...padding];\n }\n}\n\nconst mathNodeToCharArray = mn => {\n const text = mn.childNodes.reduce(reduceText, '');\n return text.split('');\n};\n\n/**\n * Convert child a column entry\n * @param {*} child\n * @return an array of column content\n */\nconst toColumnArray = child => {\n if (!child || !child.kind) {\n return [];\n }\n\n if (child.kind === 'msrow') {\n throw new Error('msrow in msrow?');\n }\n\n if (child.kind === 'mo') {\n // We are going to treat this operator as a text array.\n // It's probably going to be a decimal point\n console.warn('mo that is not 1st node in msrow?');\n return mathNodeToCharArray(child);\n // throw new Error('mo must be first child of msrow');\n }\n\n if (child.kind === 'mn') {\n return mathNodeToCharArray(child);\n }\n\n if (child.toCHTML) {\n return child;\n }\n};\n\n/**\n * convert mstack chtml childNodes into a Row\n * @param child chtml child node of mstack\n * @return Row | Line\n */\nconst rowStack = child => {\n if (!child || !child.kind) {\n return;\n }\n\n if (child.kind === 'msrow') {\n if (!child.childNodes || child.childNodes.length === 0) {\n return new Row([]);\n }\n const f = _.first(child.childNodes);\n const nodes = f && f.kind === 'mo' ? _.tail(child.childNodes) : child.childNodes;\n\n const columns = _.flatten(nodes.map(toColumnArray));\n\n return new Row(columns, f.kind === 'mo' ? f : undefined);\n }\n\n if (child.kind === 'mn') {\n const columns = mathNodeToCharArray(child);\n return new Row(columns, undefined);\n }\n\n if (child.kind === 'mo') {\n console.warn('mo on its own row?');\n return new Row([], child);\n }\n\n if (child.kind === 'msline') {\n return new Line();\n }\n\n if (child.toCHTML) {\n return new Row([child]);\n }\n};\n\n/** convert MathJax chtml tree to Row[]\n * @param mstack the root of the mathjax chtml tree\n * @return Row[]\n */\n\nexport const getStackData = mstack => {\n if (!mstack || !mstack.childNodes) {\n return [];\n }\n return _.compact(mstack.childNodes.map(rowStack));\n};\n\nexport class CHTMLmstack extends CHTMLWrapper {\n constructor(factory, node, parent = null) {\n super(factory, node, parent);\n\n this.ce = this.adaptor.document.createElement.bind(this.adaptor.document);\n }\n\n toCHTML(parent) {\n const chtml = this.standardCHTMLnode(parent);\n\n const stackData = getStackData(this);\n\n // console.log('stackData', stackData);\n const maxCols = stackData.reduce((acc, r) => {\n if (r && r.columns.length > acc) {\n acc = r.columns.length;\n }\n return acc;\n }, 0);\n\n const table = this.ce('table');\n chtml.appendChild(table);\n\n stackData.forEach(row => {\n const tr = this.ce('tr');\n table.appendChild(tr);\n\n if (row.kind === 'row') {\n const td = this.ce('td');\n tr.appendChild(td);\n if (row.operator && row.operator.toCHTML) {\n td.setAttribute('class', 'inner');\n row.operator.toCHTML(td);\n } else {\n td.textContent = '';\n }\n\n // align right for now:\n const cols = row.pad(maxCols, 'right');\n cols.forEach(c => {\n const t = this.ce('td');\n tr.appendChild(t);\n if (c === '__pad__') {\n t.textContent = '';\n } else if (typeof c === 'string') {\n t.textContent = c;\n } else if (c.kind === 'none') {\n t.textContent = '';\n } else if (c.toCHTML) {\n t.setAttribute('class', 'inner');\n c.toCHTML(t);\n }\n });\n } else if (row.kind === 'line') {\n const td = this.ce('td');\n tr.appendChild(td);\n td.setAttribute('colspan', maxCols + 1);\n td.setAttribute('class', 'mjx-line');\n td.textContent = '';\n }\n });\n }\n}\nCHTMLmstack.styles = {\n 'mjx-mstack > table': {\n 'line-height': 'initial',\n border: 'solid 0px red',\n 'border-spacing': '0em',\n 'border-collapse': 'separate'\n },\n 'mjx-mstack > table > tr': {\n 'line-height': 'initial'\n },\n 'mjx-mstack > table > tr > td': {\n // padding: '1.2rem',\n border: 'solid 0px blue',\n 'font-family': 'sans-serif',\n 'line-height': 'initial'\n },\n 'mjx-mstack > table > tr > td.inner': {\n 'font-family': 'inherit'\n },\n 'mjx-mstack > table > tr > .mjx-line': {\n padding: 0,\n 'border-top': 'solid 1px black'\n }\n};\n"],"mappings":";;;;;;;;;AAAA;;AACA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEA,IAAMA,UAAU,GAAG,SAAbA,UAAa,CAACC,GAAD,EAAMC,CAAN,EAAY;EAC7B,IAAIA,CAAC,CAACC,IAAF,IAAUD,CAAC,CAACC,IAAF,CAAOC,IAAP,KAAgB,MAA9B,EAAsC;IACpCH,GAAG,IAAIC,CAAC,CAACC,IAAF,CAAOE,IAAd;EACD;;EACD,OAAOJ,GAAP;AACD,CALD;;IAOaK,I;EACX,gBAAc;IAAA;;IACZ,KAAKF,IAAL,GAAY,MAAZ;EACD;;;;SAED,eAAc;MACZ,OAAO,EAAP;IACD;;;;;;;;IAGUG,G;EACX,aAAYC,OAAZ,EAAqBC,QAArB,EAA+B;IAAA;;IAC7B,KAAKL,IAAL,GAAY,KAAZ;IACA,KAAKK,QAAL,GAAgBA,QAAhB;IACA,KAAKD,OAAL,GAAeA,OAAf;EACD;;;;WAED,aAAIE,KAAJ,EAAgC;MAAA,IAArBC,SAAqB,uEAAT,OAAS;;MAC9B,IAAID,KAAK,GAAG,KAAKF,OAAL,CAAaI,MAAzB,EAAiC;QAC/B,MAAM,IAAIC,KAAJ,CAAU,IAAV,CAAN;MACD;;MAED,IAAMC,IAAI,GAAGJ,KAAK,GAAG,KAAKF,OAAL,CAAaI,MAAlC;;MAEA,IAAMG,OAAO,GAAGC,kBAAA,CAAEC,KAAF,CAAQH,IAAR,EAAcI,GAAd,CAAkB,UAAAhB,CAAC;QAAA,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I,GAAf;;UACAA,GAAE,CAACC,YAAH,CAAgB,SAAhB,EAA2BR,OAAO,GAAG,CAArC;;UACAO,GAAE,CAACC,YAAH,CAAgB,OAAhB,EAAyB,UAAzB;;UACAD,GAAE,CAACE,WAAH,GAAiB,EAAjB;QACD;MACF,CArCD;IAsCD;;;;EA7D8BK,qB;;;AA+DjCzB,WAAW,CAAC0B,MAAZ,GAAqB;EACnB,sBAAsB;IACpB,eAAe,SADK;IAEpBC,MAAM,EAAE,eAFY;IAGpB,kBAAkB,KAHE;IAIpB,mBAAmB;EAJC,CADH;EAOnB,2BAA2B;IACzB,eAAe;EADU,CAPR;EAUnB,gCAAgC;IAC9B;IACAA,MAAM,EAAE,gBAFsB;IAG9B,eAAe,YAHe;IAI9B,eAAe;EAJe,CAVb;EAgBnB,sCAAsC;IACpC,eAAe;EADqB,CAhBnB;EAmBnB,uCAAuC;IACrCnD,OAAO,EAAE,CAD4B;IAErC,cAAc;EAFuB;AAnBpB,CAArB"}
1
+ {"version":3,"file":"chtml.js","names":["reduceText","acc","n","node","kind","text","Line","Row","columns","operator","count","direction","length","Error","diff","padding","_","times","map","mathNodeToCharArray","mn","childNodes","reduce","split","toColumnArray","child","console","warn","toCHTML","rowStack","f","first","nodes","tail","flatten","undefined","getStackData","mstack","compact","CHTMLmstack","factory","parent","ce","adaptor","document","createElement","bind","chtml","standardCHTMLnode","stackData","maxCols","r","table","appendChild","forEach","row","tr","td","setAttribute","textContent","cols","pad","c","t","CHTMLWrapper","styles","border"],"sources":["../../src/mstack/chtml.js"],"sourcesContent":["import { CHTMLWrapper } from 'mathjax-full/js/output/chtml/Wrapper';\nimport _ from 'lodash';\n\nconst reduceText = (acc, n) => {\n if (n.node && n.node.kind === 'text') {\n acc += n.node.text;\n }\n return acc;\n};\n\nexport class Line {\n constructor() {\n this.kind = 'line';\n }\n\n get columns() {\n return [];\n }\n}\n\nexport class Row {\n constructor(columns, operator) {\n this.kind = 'row';\n this.operator = operator;\n this.columns = columns;\n }\n\n pad(count, direction = 'right') {\n if (count < this.columns.length) {\n throw new Error('no');\n }\n\n const diff = count - this.columns.length;\n\n const padding = _.times(diff).map(n => '__pad__');\n return direction === 'right' ? [...padding, ...this.columns] : [...this.columns, ...padding];\n }\n}\n\nconst mathNodeToCharArray = mn => {\n const text = mn.childNodes.reduce(reduceText, '');\n return text.split('');\n};\n\n/**\n * Convert child a column entry\n * @param {*} child\n * @return an array of column content\n */\nconst toColumnArray = child => {\n if (!child || !child.kind) {\n return [];\n }\n\n if (child.kind === 'msrow') {\n throw new Error('msrow in msrow?');\n }\n\n if (child.kind === 'mo') {\n // We are going to treat this operator as a text array.\n // It's probably going to be a decimal point\n console.warn('mo that is not 1st node in msrow?');\n return mathNodeToCharArray(child);\n // throw new Error('mo must be first child of msrow');\n }\n\n if (child.kind === 'mn') {\n return mathNodeToCharArray(child);\n }\n\n if (child.toCHTML) {\n return child;\n }\n};\n\n/**\n * convert mstack chtml childNodes into a Row\n * @param child chtml child node of mstack\n * @return Row | Line\n */\nconst rowStack = child => {\n if (!child || !child.kind) {\n return;\n }\n\n if (child.kind === 'msrow') {\n if (!child.childNodes || child.childNodes.length === 0) {\n return new Row([]);\n }\n const f = _.first(child.childNodes);\n const nodes = f && f.kind === 'mo' ? _.tail(child.childNodes) : child.childNodes;\n\n const columns = _.flatten(nodes.map(toColumnArray));\n\n return new Row(columns, f.kind === 'mo' ? f : undefined);\n }\n\n if (child.kind === 'mn') {\n const columns = mathNodeToCharArray(child);\n return new Row(columns, undefined);\n }\n\n if (child.kind === 'mo') {\n console.warn('mo on its own row?');\n return new Row([], child);\n }\n\n if (child.kind === 'msline') {\n return new Line();\n }\n\n if (child.toCHTML) {\n return new Row([child]);\n }\n};\n\n/** convert MathJax chtml tree to Row[]\n * @param mstack the root of the mathjax chtml tree\n * @return Row[]\n */\n\nexport const getStackData = mstack => {\n if (!mstack || !mstack.childNodes) {\n return [];\n }\n return _.compact(mstack.childNodes.map(rowStack));\n};\n\nexport class CHTMLmstack extends CHTMLWrapper {\n constructor(factory, node, parent = null) {\n super(factory, node, parent);\n\n this.ce = this.adaptor.document.createElement.bind(this.adaptor.document);\n }\n\n toCHTML(parent) {\n const chtml = this.standardCHTMLnode(parent);\n\n const stackData = getStackData(this);\n\n // console.log('stackData', stackData);\n const maxCols = stackData.reduce((acc, r) => {\n if (r && r.columns.length > acc) {\n acc = r.columns.length;\n }\n return acc;\n }, 0);\n\n const table = this.ce('table');\n chtml.appendChild(table);\n\n stackData.forEach(row => {\n const tr = this.ce('tr');\n table.appendChild(tr);\n\n if (row.kind === 'row') {\n const td = this.ce('td');\n tr.appendChild(td);\n if (row.operator && row.operator.toCHTML) {\n td.setAttribute('class', 'inner');\n row.operator.toCHTML(td);\n } else {\n td.textContent = '';\n }\n\n // align right for now:\n const cols = row.pad(maxCols, 'right');\n cols.forEach(c => {\n const t = this.ce('td');\n tr.appendChild(t);\n if (c === '__pad__') {\n t.textContent = '';\n } else if (typeof c === 'string') {\n t.textContent = c;\n } else if (c.kind === 'none') {\n t.textContent = '';\n } else if (c.toCHTML) {\n t.setAttribute('class', 'inner');\n c.toCHTML(t);\n }\n });\n } else if (row.kind === 'line') {\n const td = this.ce('td');\n tr.appendChild(td);\n td.setAttribute('colspan', maxCols + 1);\n td.setAttribute('class', 'mjx-line');\n td.textContent = '';\n }\n });\n }\n}\nCHTMLmstack.styles = {\n 'mjx-mstack > table': {\n 'line-height': 'initial',\n border: 'solid 0px red',\n 'border-spacing': '0em',\n 'border-collapse': 'separate'\n },\n 'mjx-mstack > table > tr': {\n 'line-height': 'initial'\n },\n 'mjx-mstack > table > tr > td': {\n // padding: '1.2rem',\n border: 'solid 0px blue',\n 'font-family': 'sans-serif',\n 'line-height': 'initial'\n },\n 'mjx-mstack > table > tr > td.inner': {\n 'font-family': 'inherit'\n },\n 'mjx-mstack > table > tr > .mjx-line': {\n padding: 0,\n 'border-top': 'solid 1px black'\n },\n '.TEX-A': {\n 'font-family': 'MJXZERO, MJXTEX !important'\n }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,kBAAkB,KAHE;IAIpB,mBAAmB;EAJC,CADH;EAOnB,2BAA2B;IACzB,eAAe;EADU,CAPR;EAUnB,gCAAgC;IAC9B;IACAA,MAAM,EAAE,gBAFsB;IAG9B,eAAe,YAHe;IAI9B,eAAe;EAJe,CAVb;EAgBnB,sCAAsC;IACpC,eAAe;EADqB,CAhBnB;EAmBnB,uCAAuC;IACrCnD,OAAO,EAAE,CAD4B;IAErC,cAAc;EAFuB,CAnBpB;EAuBnB,UAAU;IACR,eAAe;EADP;AAvBS,CAArB"}
package/lib/mstack/mml.js CHANGED
@@ -1,121 +1,107 @@
1
1
  "use strict";
2
2
 
3
- function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
4
 
5
5
  Object.defineProperty(exports, "__esModule", {
6
6
  value: true
7
7
  });
8
8
  exports.MmlNone = exports.MmlMstack = exports.MmlMsrow = exports.MmlMsline = void 0;
9
9
 
10
- var _MmlNode = require("mathjax-full/js/core/MmlTree/MmlNode");
11
-
12
- function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
10
+ var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
13
11
 
14
- function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
12
+ var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
15
13
 
16
- function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
14
+ var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
17
15
 
18
- function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); }
16
+ var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
19
17
 
20
- function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
18
+ var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
21
19
 
22
- function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
23
-
24
- function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); }
20
+ var _MmlNode = require("mathjax-full/js/core/MmlTree/MmlNode");
25
21
 
26
- function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
22
+ function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2["default"])(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2["default"])(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2["default"])(this, result); }; }
27
23
 
28
24
  function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
29
25
 
30
- function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
31
-
32
26
  var MmlNone = /*#__PURE__*/function (_AbstractMmlNode) {
33
- _inherits(MmlNone, _AbstractMmlNode);
27
+ (0, _inherits2["default"])(MmlNone, _AbstractMmlNode);
34
28
 
35
29
  var _super = _createSuper(MmlNone);
36
30
 
37
31
  function MmlNone() {
38
- _classCallCheck(this, MmlNone);
39
-
32
+ (0, _classCallCheck2["default"])(this, MmlNone);
40
33
  return _super.apply(this, arguments);
41
34
  }
42
35
 
43
- _createClass(MmlNone, [{
36
+ (0, _createClass2["default"])(MmlNone, [{
44
37
  key: "kind",
45
38
  get: function get() {
46
39
  return 'none';
47
40
  }
48
41
  }]);
49
-
50
42
  return MmlNone;
51
43
  }(_MmlNode.AbstractMmlNode);
52
44
 
53
45
  exports.MmlNone = MmlNone;
54
46
 
55
47
  var MmlMstack = /*#__PURE__*/function (_AbstractMmlNode2) {
56
- _inherits(MmlMstack, _AbstractMmlNode2);
48
+ (0, _inherits2["default"])(MmlMstack, _AbstractMmlNode2);
57
49
 
58
50
  var _super2 = _createSuper(MmlMstack);
59
51
 
60
52
  function MmlMstack() {
61
- _classCallCheck(this, MmlMstack);
62
-
53
+ (0, _classCallCheck2["default"])(this, MmlMstack);
63
54
  return _super2.apply(this, arguments);
64
55
  }
65
56
 
66
- _createClass(MmlMstack, [{
57
+ (0, _createClass2["default"])(MmlMstack, [{
67
58
  key: "kind",
68
59
  get: function get() {
69
60
  return 'mstack';
70
61
  }
71
62
  }]);
72
-
73
63
  return MmlMstack;
74
64
  }(_MmlNode.AbstractMmlNode);
75
65
 
76
66
  exports.MmlMstack = MmlMstack;
77
67
 
78
68
  var MmlMsrow = /*#__PURE__*/function (_AbstractMmlNode3) {
79
- _inherits(MmlMsrow, _AbstractMmlNode3);
69
+ (0, _inherits2["default"])(MmlMsrow, _AbstractMmlNode3);
80
70
 
81
71
  var _super3 = _createSuper(MmlMsrow);
82
72
 
83
73
  function MmlMsrow() {
84
- _classCallCheck(this, MmlMsrow);
85
-
74
+ (0, _classCallCheck2["default"])(this, MmlMsrow);
86
75
  return _super3.apply(this, arguments);
87
76
  }
88
77
 
89
- _createClass(MmlMsrow, [{
78
+ (0, _createClass2["default"])(MmlMsrow, [{
90
79
  key: "kind",
91
80
  get: function get() {
92
81
  return 'msrow';
93
82
  }
94
83
  }]);
95
-
96
84
  return MmlMsrow;
97
85
  }(_MmlNode.AbstractMmlNode);
98
86
 
99
87
  exports.MmlMsrow = MmlMsrow;
100
88
 
101
89
  var MmlMsline = /*#__PURE__*/function (_AbstractMmlNode4) {
102
- _inherits(MmlMsline, _AbstractMmlNode4);
90
+ (0, _inherits2["default"])(MmlMsline, _AbstractMmlNode4);
103
91
 
104
92
  var _super4 = _createSuper(MmlMsline);
105
93
 
106
94
  function MmlMsline() {
107
- _classCallCheck(this, MmlMsline);
108
-
95
+ (0, _classCallCheck2["default"])(this, MmlMsline);
109
96
  return _super4.apply(this, arguments);
110
97
  }
111
98
 
112
- _createClass(MmlMsline, [{
99
+ (0, _createClass2["default"])(MmlMsline, [{
113
100
  key: "kind",
114
101
  get: function get() {
115
102
  return 'msline';
116
103
  }
117
104
  }]);
118
-
119
105
  return MmlMsline;
120
106
  }(_MmlNode.AbstractMmlNode);
121
107
 
@@ -1 +1 @@
1
- {"version":3,"file":"mml.js","names":["MmlNone","AbstractMmlNode","MmlMstack","MmlMsrow","MmlMsline"],"sources":["../../src/mstack/mml.js"],"sourcesContent":["import { AbstractMmlNode } from 'mathjax-full/js/core/MmlTree/MmlNode';\n\nexport class MmlNone extends AbstractMmlNode {\n get kind() {\n return 'none';\n }\n}\n\nexport class MmlMstack extends AbstractMmlNode {\n get kind() {\n return 'mstack';\n }\n}\n\nexport class MmlMsrow extends AbstractMmlNode {\n get kind() {\n return 'msrow';\n }\n}\nexport class MmlMsline extends AbstractMmlNode {\n get kind() {\n return 'msline';\n }\n}\n"],"mappings":";;;;;;;;;AAAA;;;;;;;;;;;;;;;;;;;;;;IAEaA,O;;;;;;;;;;;;;SACX,eAAW;MACT,OAAO,MAAP;IACD;;;;EAH0BC,wB;;;;IAMhBC,S;;;;;;;;;;;;;SACX,eAAW;MACT,OAAO,QAAP;IACD;;;;EAH4BD,wB;;;;IAMlBE,Q;;;;;;;;;;;;;SACX,eAAW;MACT,OAAO,OAAP;IACD;;;;EAH2BF,wB;;;;IAKjBG,S;;;;;;;;;;;;;SACX,eAAW;MACT,OAAO,QAAP;IACD;;;;EAH4BH,wB"}
1
+ {"version":3,"file":"mml.js","names":["MmlNone","AbstractMmlNode","MmlMstack","MmlMsrow","MmlMsline"],"sources":["../../src/mstack/mml.js"],"sourcesContent":["import { AbstractMmlNode } from 'mathjax-full/js/core/MmlTree/MmlNode';\n\nexport class MmlNone extends AbstractMmlNode {\n get kind() {\n return 'none';\n }\n}\n\nexport class MmlMstack extends AbstractMmlNode {\n get kind() {\n return 'mstack';\n }\n}\n\nexport class MmlMsrow extends AbstractMmlNode {\n get kind() {\n return 'msrow';\n }\n}\nexport class MmlMsline extends AbstractMmlNode {\n get kind() {\n return 'msline';\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAAA;;;;;;IAEaA,O;;;;;;;;;;;;SACX,eAAW;MACT,OAAO,MAAP;IACD;;;EAH0BC,wB;;;;IAMhBC,S;;;;;;;;;;;;SACX,eAAW;MACT,OAAO,QAAP;IACD;;;EAH4BD,wB;;;;IAMlBE,Q;;;;;;;;;;;;SACX,eAAW;MACT,OAAO,OAAP;IACD;;;EAH2BF,wB;;;;IAKjBG,S;;;;;;;;;;;;SACX,eAAW;MACT,OAAO,QAAP;IACD;;;EAH4BH,wB"}
@@ -1,25 +1,17 @@
1
1
  "use strict";
2
2
 
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+
3
5
  Object.defineProperty(exports, "__esModule", {
4
6
  value: true
5
7
  });
6
8
  exports.wrapMath = exports.unWrapMath = exports.BracketTypes = void 0;
7
9
 
8
- var _PAIRS;
9
-
10
- function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
11
-
12
- function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
10
+ var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
13
11
 
14
- function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
12
+ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
15
13
 
16
- function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
17
-
18
- function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
19
-
20
- function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
21
-
22
- function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
14
+ var _PAIRS;
23
15
 
24
16
  var BracketTypes = {};
25
17
  exports.BracketTypes = BracketTypes;
@@ -27,7 +19,7 @@ BracketTypes.ROUND_BRACKETS = 'round_brackets';
27
19
  BracketTypes.SQUARE_BRACKETS = 'square_brackets';
28
20
  BracketTypes.DOLLAR = 'dollar';
29
21
  BracketTypes.DOUBLE_DOLLAR = 'double_dollar';
30
- var PAIRS = (_PAIRS = {}, _defineProperty(_PAIRS, BracketTypes.ROUND_BRACKETS, ['\\(', '\\)']), _defineProperty(_PAIRS, BracketTypes.SQUARE_BRACKETS, ['\\[', '\\]']), _defineProperty(_PAIRS, BracketTypes.DOLLAR, ['$', '$']), _defineProperty(_PAIRS, BracketTypes.DOUBLE_DOLLAR, ['$$', '$$']), _PAIRS);
22
+ var PAIRS = (_PAIRS = {}, (0, _defineProperty2["default"])(_PAIRS, BracketTypes.ROUND_BRACKETS, ['\\(', '\\)']), (0, _defineProperty2["default"])(_PAIRS, BracketTypes.SQUARE_BRACKETS, ['\\[', '\\]']), (0, _defineProperty2["default"])(_PAIRS, BracketTypes.DOLLAR, ['$', '$']), (0, _defineProperty2["default"])(_PAIRS, BracketTypes.DOUBLE_DOLLAR, ['$$', '$$']), _PAIRS);
31
23
 
32
24
  var wrapMath = function wrapMath(content, wrapType) {
33
25
  if (wrapType === BracketTypes.SQUARE_BRACKETS) {
@@ -43,7 +35,7 @@ var wrapMath = function wrapMath(content, wrapType) {
43
35
  }
44
36
 
45
37
  var _ref = PAIRS[wrapType] || PAIRS[BracketTypes.ROUND_BRACKETS],
46
- _ref2 = _slicedToArray(_ref, 2),
38
+ _ref2 = (0, _slicedToArray2["default"])(_ref, 2),
47
39
  start = _ref2[0],
48
40
  end = _ref2[1];
49
41
 
@@ -1 +1 @@
1
- {"version":3,"file":"normalization.js","names":["BracketTypes","ROUND_BRACKETS","SQUARE_BRACKETS","DOLLAR","DOUBLE_DOLLAR","PAIRS","wrapMath","content","wrapType","console","warn","start","end","unWrapMath","displayStyleIndex","indexOf","replace","trim","startsWith","endsWith","unwrapped","substring","length"],"sources":["../src/normalization.js"],"sourcesContent":["export const BracketTypes = {};\n\nBracketTypes.ROUND_BRACKETS = 'round_brackets';\nBracketTypes.SQUARE_BRACKETS = 'square_brackets';\nBracketTypes.DOLLAR = 'dollar';\nBracketTypes.DOUBLE_DOLLAR = 'double_dollar';\n\nconst PAIRS = {\n [BracketTypes.ROUND_BRACKETS]: ['\\\\(', '\\\\)'],\n [BracketTypes.SQUARE_BRACKETS]: ['\\\\[', '\\\\]'],\n [BracketTypes.DOLLAR]: ['$', '$'],\n [BracketTypes.DOUBLE_DOLLAR]: ['$$', '$$']\n};\n\nexport const wrapMath = (content, wrapType) => {\n if (wrapType === BracketTypes.SQUARE_BRACKETS) {\n console.warn('\\\\[...\\\\] is not supported yet'); // eslint-disable-line\n wrapType = BracketTypes.ROUND_BRACKETS;\n }\n if (wrapType === BracketTypes.DOUBLE_DOLLAR) {\n console.warn('$$...$$ is not supported yet'); // eslint-disable-line\n wrapType = BracketTypes.DOLLAR;\n }\n\n const [start, end] = PAIRS[wrapType] || PAIRS[BracketTypes.ROUND_BRACKETS];\n return `${start}${content}${end}`;\n};\n\nexport const unWrapMath = content => {\n const displayStyleIndex = content.indexOf('\\\\displaystyle');\n if (displayStyleIndex !== -1) {\n console.warn('\\\\displaystyle is not supported - removing'); // eslint-disable-line\n content = content.replace('\\\\displaystyle', '').trim();\n }\n\n if (content.startsWith('$$') && content.endsWith('$$')) {\n console.warn('$$ syntax is not yet supported'); // eslint-disable-line\n return {\n unwrapped: content.substring(2, content.length - 2),\n wrapType: BracketTypes.DOLLAR\n };\n }\n if (content.startsWith('$') && content.endsWith('$')) {\n return {\n unwrapped: content.substring(1, content.length - 1),\n wrapType: BracketTypes.DOLLAR\n };\n }\n\n if (content.startsWith('\\\\[') && content.endsWith('\\\\]')) {\n console.warn('\\\\[..\\\\] syntax is not yet supported'); // eslint-disable-line\n return {\n unwrapped: content.substring(2, content.length - 2),\n wrapType: BracketTypes.ROUND_BRACKETS\n };\n }\n\n if (content.startsWith('\\\\(') && content.endsWith('\\\\)')) {\n return {\n unwrapped: content.substring(2, content.length - 2),\n wrapType: BracketTypes.ROUND_BRACKETS\n };\n }\n\n return {\n unwrapped: content,\n wrapType: BracketTypes.ROUND_BRACKETS\n };\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAAO,IAAMA,YAAY,GAAG,EAArB;;AAEPA,YAAY,CAACC,cAAb,GAA8B,gBAA9B;AACAD,YAAY,CAACE,eAAb,GAA+B,iBAA/B;AACAF,YAAY,CAACG,MAAb,GAAsB,QAAtB;AACAH,YAAY,CAACI,aAAb,GAA6B,eAA7B;AAEA,IAAMC,KAAK,yCACRL,YAAY,CAACC,cADL,EACsB,CAAC,KAAD,EAAQ,KAAR,CADtB,2BAERD,YAAY,CAACE,eAFL,EAEuB,CAAC,KAAD,EAAQ,KAAR,CAFvB,2BAGRF,YAAY,CAACG,MAHL,EAGc,CAAC,GAAD,EAAM,GAAN,CAHd,2BAIRH,YAAY,CAACI,aAJL,EAIqB,CAAC,IAAD,EAAO,IAAP,CAJrB,UAAX;;AAOO,IAAME,QAAQ,GAAG,SAAXA,QAAW,CAACC,OAAD,EAAUC,QAAV,EAAuB;EAC7C,IAAIA,QAAQ,KAAKR,YAAY,CAACE,eAA9B,EAA+C;IAC7CO,OAAO,CAACC,IAAR,CAAa,gCAAb,EAD6C,CACG;;IAChDF,QAAQ,GAAGR,YAAY,CAACC,cAAxB;EACD;;EACD,IAAIO,QAAQ,KAAKR,YAAY,CAACI,aAA9B,EAA6C;IAC3CK,OAAO,CAACC,IAAR,CAAa,8BAAb,EAD2C,CACG;;IAC9CF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ACxDV,OAAO,CAACC,IAAR,CAAa,sCAAb,EADwD,CACF;;IACtD,OAAO;MACLU,SAAS,EAAEb,OAAO,CAACc,SAAR,CAAkB,CAAlB,EAAqBd,OAAO,CAACe,MAAR,GAAiB,CAAtC,CADN;MAELd,QAAQ,EAAER,YAAY,CAACC;IAFlB,CAAP;EAID;;EAED,IAAIM,OAAO,CAACW,UAAR,CAAmB,KAAnB,KAA6BX,OAAO,CAACY,QAAR,CAAiB,KAAjB,CAAjC,EAA0D;IACxD,OAAO;MACLC,SAAS,EAAEb,OAAO,CAACc,SAAR,CAAkB,CAAlB,EAAqBd,OAAO,CAACe,MAAR,GAAiB,CAAtC,CADN;MAELd,QAAQ,EAAER,YAAY,CAACC;IAFlB,CAAP;EAID;;EAED,OAAO;IACLmB,SAAS,EAAEb,OADN;IAELC,QAAQ,EAAER,YAAY,CAACC;EAFlB,CAAP;AAID,CAxCM"}
1
+ {"version":3,"file":"normalization.js","names":["BracketTypes","ROUND_BRACKETS","SQUARE_BRACKETS","DOLLAR","DOUBLE_DOLLAR","PAIRS","wrapMath","content","wrapType","console","warn","start","end","unWrapMath","displayStyleIndex","indexOf","replace","trim","startsWith","endsWith","unwrapped","substring","length"],"sources":["../src/normalization.js"],"sourcesContent":["export const BracketTypes = {};\n\nBracketTypes.ROUND_BRACKETS = 'round_brackets';\nBracketTypes.SQUARE_BRACKETS = 'square_brackets';\nBracketTypes.DOLLAR = 'dollar';\nBracketTypes.DOUBLE_DOLLAR = 'double_dollar';\n\nconst PAIRS = {\n [BracketTypes.ROUND_BRACKETS]: ['\\\\(', '\\\\)'],\n [BracketTypes.SQUARE_BRACKETS]: ['\\\\[', '\\\\]'],\n [BracketTypes.DOLLAR]: ['$', '$'],\n [BracketTypes.DOUBLE_DOLLAR]: ['$$', '$$']\n};\n\nexport const wrapMath = (content, wrapType) => {\n if (wrapType === BracketTypes.SQUARE_BRACKETS) {\n console.warn('\\\\[...\\\\] is not supported yet'); // eslint-disable-line\n wrapType = BracketTypes.ROUND_BRACKETS;\n }\n if (wrapType === BracketTypes.DOUBLE_DOLLAR) {\n console.warn('$$...$$ is not supported yet'); // eslint-disable-line\n wrapType = BracketTypes.DOLLAR;\n }\n\n const [start, end] = PAIRS[wrapType] || PAIRS[BracketTypes.ROUND_BRACKETS];\n return `${start}${content}${end}`;\n};\n\nexport const unWrapMath = content => {\n const displayStyleIndex = content.indexOf('\\\\displaystyle');\n if (displayStyleIndex !== -1) {\n console.warn('\\\\displaystyle is not supported - removing'); // eslint-disable-line\n content = content.replace('\\\\displaystyle', '').trim();\n }\n\n if (content.startsWith('$$') && content.endsWith('$$')) {\n console.warn('$$ syntax is not yet supported'); // eslint-disable-line\n return {\n unwrapped: content.substring(2, content.length - 2),\n wrapType: BracketTypes.DOLLAR\n };\n }\n if (content.startsWith('$') && content.endsWith('$')) {\n return {\n unwrapped: content.substring(1, content.length - 1),\n wrapType: BracketTypes.DOLLAR\n };\n }\n\n if (content.startsWith('\\\\[') && content.endsWith('\\\\]')) {\n console.warn('\\\\[..\\\\] syntax is not yet supported'); // eslint-disable-line\n return {\n unwrapped: content.substring(2, content.length - 2),\n wrapType: BracketTypes.ROUND_BRACKETS\n };\n }\n\n if (content.startsWith('\\\\(') && content.endsWith('\\\\)')) {\n return {\n unwrapped: content.substring(2, content.length - 2),\n wrapType: BracketTypes.ROUND_BRACKETS\n };\n }\n\n return {\n unwrapped: content,\n wrapType: BracketTypes.ROUND_BRACKETS\n };\n};\n"],"mappings":";;;;;;;;;;;;;;;AAAO,IAAMA,YAAY,GAAG,EAArB;;AAEPA,YAAY,CAACC,cAAb,GAA8B,gBAA9B;AACAD,YAAY,CAACE,eAAb,GAA+B,iBAA/B;AACAF,YAAY,CAACG,MAAb,GAAsB,QAAtB;AACAH,YAAY,CAACI,aAAb,GAA6B,eAA7B;AAEA,IAAMC,KAAK,0DACRL,YAAY,CAACC,cADL,EACsB,CAAC,KAAD,EAAQ,KAAR,CADtB,4CAERD,YAAY,CAACE,eAFL,EA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AAO;MACLU,SAAS,EAAEb,OAAO,CAACc,SAAR,CAAkB,CAAlB,EAAqBd,OAAO,CAACe,MAAR,GAAiB,CAAtC,CADN;MAELd,QAAQ,EAAER,YAAY,CAACG;IAFlB,CAAP;EAID;;EACD,IAAII,OAAO,CAACW,UAAR,CAAmB,GAAnB,KAA2BX,OAAO,CAACY,QAAR,CAAiB,GAAjB,CAA/B,EAAsD;IACpD,OAAO;MACLC,SAAS,EAAEb,OAAO,CAACc,SAAR,CAAkB,CAAlB,EAAqBd,OAAO,CAACe,MAAR,GAAiB,CAAtC,CADN;MAELd,QAAQ,EAAER,YAAY,CAACG;IAFlB,CAAP;EAID;;EAED,IAAII,OAAO,CAACW,UAAR,CAAmB,KAAnB,KAA6BX,OAAO,CAACY,QAAR,CAAiB,KAAjB,CAAjC,EAA0D;IACxDV,OAAO,CAACC,IAAR,CAAa,sCAAb,EADwD,CACF;;IACtD,OAAO;MACLU,SAAS,EAAEb,OAAO,CAACc,SAAR,CAAkB,CAAlB,EAAqBd,OAAO,CAACe,MAAR,GAAiB,CAAtC,CADN;MAELd,QAAQ,EAAER,YAAY,CAACC;IAFlB,CAAP;EAID;;EAED,IAAIM,OAAO,CAACW,UAAR,CAAmB,KAAnB,KAA6BX,OAAO,CAACY,QAAR,CAAiB,KAAjB,CAAjC,EAA0D;IACxD,OAAO;MACLC,SAAS,EAAEb,OAAO,CAACc,SAAR,CAAkB,CAAlB,EAAqBd,OAAO,CAACe,MAAR,GAAiB,CAAtC,CADN;MAELd,QAAQ,EAAER,YAAY,CAACC;IAFlB,CAAP;EAID;;EAED,OAAO;IACLmB,SAAS,EAAEb,OADN;IAELC,QAAQ,EAAER,YAAY,CAACC;EAFlB,CAAP;AAID,CAxCM"}
@@ -1,10 +1,18 @@
1
1
  "use strict";
2
2
 
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+
3
5
  Object.defineProperty(exports, "__esModule", {
4
6
  value: true
5
7
  });
6
8
  exports.fixMathElements = exports.fixMathElement = exports["default"] = void 0;
7
9
 
10
+ var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
11
+
12
+ var _typeof2 = _interopRequireDefault(require("@babel/runtime/helpers/typeof"));
13
+
14
+ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
15
+
8
16
  var _mathjax = require("mathjax-full/js/mathjax");
9
17
 
10
18
  var _mathml = require("mathjax-full/js/input/mathml");
@@ -35,27 +43,9 @@ var _WrapperFactory = require("mathjax-full/js/output/chtml/WrapperFactory");
35
43
 
36
44
  var _mspace = require("mathjax-full/js/output/chtml/Wrappers/mspace");
37
45
 
38
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
39
-
40
- function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
41
-
42
- function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
43
-
44
- function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
45
-
46
- function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
47
-
48
- function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
49
-
50
- function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
51
-
52
- function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
53
-
54
46
  function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
55
47
 
56
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
57
-
58
- function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
48
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { (0, _defineProperty2["default"])(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
59
49
 
60
50
  if (typeof window !== 'undefined') {
61
51
  (0, _html.RegisterHTMLHandler)((0, _browserAdaptor.browserAdaptor)());
@@ -98,6 +88,10 @@ var defaultOpts = function defaultOpts() {
98
88
  };
99
89
 
100
90
  var fixMathElement = function fixMathElement(element) {
91
+ if (element.dataset.mathHandled) {
92
+ return;
93
+ }
94
+
101
95
  var property = 'innerText';
102
96
 
103
97
  if (element.textContent) {
@@ -109,6 +103,7 @@ var fixMathElement = function fixMathElement(element) {
109
103
  // we need to replace the custom embedded elements with valid latex that Mathjax can understand
110
104
 
111
105
  element[property] = element[property].replace(NEWLINE_BLOCK_REGEX, NEWLINE_LATEX);
106
+ element.dataset.mathHandled = true;
112
107
  }
113
108
  };
114
109
 
@@ -161,21 +156,15 @@ var bootstrap = function bootstrap(opts) {
161
156
  longdiv: '\\enclose{longdiv}'
162
157
  };
163
158
  var texConfig = opts.useSingleDollar ? {
164
- loader: {
165
- require: require
166
- },
167
159
  packages: packages,
168
160
  macros: macros,
169
161
  inlineMath: [['$', '$'], ['\\(', '\\)']],
170
- displayMath: [['$$', '$$'], ['\\[', '\\]']],
171
162
  processEscapes: true
172
163
  } : {
173
164
  packages: packages,
174
165
  macros: macros
175
166
  };
176
167
  var mmlConfig = {
177
- parseAs: 'html',
178
- forceReparse: false,
179
168
  parseError: function parseError(node) {
180
169
  // function to process parsing errors
181
170
  console.log('error:', node);
@@ -188,7 +177,6 @@ var bootstrap = function bootstrap(opts) {
188
177
  wrapperFactory: new _WrapperFactory.CHTMLWrapperFactory(_objectSpread(_objectSpread({}, _WrapperFactory.CHTMLWrapperFactory.defaultNodes), _mstack.chtmlNodes))
189
178
  };
190
179
  var mml = new _mathml.MathML(mmlConfig);
191
- console.log([new _tex.TeX(texConfig), mml]);
192
180
  var customMmlFactory = new _MmlFactory.MmlFactory(_objectSpread(_objectSpread({}, _MmlFactory.MmlFactory.defaultNodes), _mstack.mmlNodes));
193
181
 
194
182
  var html = _mathjax.mathjax.document(document, {
@@ -222,7 +210,7 @@ var bootstrap = function bootstrap(opts) {
222
210
  try {
223
211
  var list = updatedDocument.math.list;
224
212
 
225
- for (var item = list.next; _typeof(item.data) !== 'symbol'; item = item.next) {
213
+ for (var item = list.next; (0, _typeof2["default"])(item.data) !== 'symbol'; item = item.next) {
226
214
  var mathMl = toMMl(item.data.root);
227
215
  var parsedMathMl = mathMl.replaceAll('\n', '');
228
216
  item.data.typesetRoot.setAttribute('data-mathml', parsedMathMl);
@@ -257,7 +245,7 @@ var renderMath = function renderMath(el, renderOpts) {
257
245
 
258
246
  var arr = Array.from(el);
259
247
 
260
- (_getGlobal$instance = getGlobal().instance).Typeset.apply(_getGlobal$instance, _toConsumableArray(arr));
248
+ (_getGlobal$instance = getGlobal().instance).Typeset.apply(_getGlobal$instance, (0, _toConsumableArray2["default"])(arr));
261
249
  }
262
250
  };
263
251
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"render-math.js","names":["window","RegisterHTMLHandler","browserAdaptor","visitor","SerializedMmlVisitor","toMMl","node","visitTree","log","debug","NEWLINE_BLOCK_REGEX","NEWLINE_LATEX","getGlobal","key","pkg","name","version","split","defaultOpts","opts","fixMathElement","element","property","textContent","wrapMath","unWrapMath","unwrapped","replace","fixMathElements","mathElements","document","querySelectorAll","forEach","item","adjustMathMLStyle","nodes","setAttribute","bootstrap","Typeset","useSingleDollar","console","warn","packages","AllPackages","filter","push","macros","parallelogram","overarc","napprox","longdiv","texConfig","loader","require","inlineMath","displayMath","processEscapes","mmlConfig","parseAs","forceReparse","parseError","error","adaptor","fontURL","mathjax","htmlConfig","wrapperFactory","CHTMLWrapperFactory","defaultNodes","chtmlNodes","mml","MathML","TeX","customMmlFactory","MmlFactory","mmlNodes","html","compileError","mj","math","err","typesetError","doc","InputJax","OutputJax","CHTML","setMmlFactory","elements","updatedDocument","findMath","length","compile","getMetrics","typeset","updateDocument","list","next","data","mathMl","root","parsedMathMl","replaceAll","typesetRoot","e","toString","clear","renderMath","el","renderOpts","instance","Element","arr","Array","from","CHTMLmspace","styles","display","height"],"sources":["../src/render-math.js"],"sourcesContent":["import { mathjax } from 'mathjax-full/js/mathjax';\nimport { MathML } from 'mathjax-full/js/input/mathml';\nimport { TeX } from 'mathjax-full/js/input/tex';\n\nimport { CHTML } from 'mathjax-full/js/output/chtml';\nimport { RegisterHTMLHandler } from 'mathjax-full/js/handlers/html';\nimport { browserAdaptor } from 'mathjax-full/js/adaptors/browserAdaptor';\nimport { AllPackages } from 'mathjax-full/js/input/tex/AllPackages';\n\nif (typeof window !== 'undefined') {\n RegisterHTMLHandler(browserAdaptor());\n}\n\nimport pkg from '../package.json';\nimport { mmlNodes, chtmlNodes } from './mstack';\nimport debug from 'debug';\nimport { wrapMath, unWrapMath } from './normalization';\nimport { MmlFactory } from 'mathjax-full/js/core/MmlTree/MmlFactory';\nimport { SerializedMmlVisitor } from 'mathjax-full/js/core/MmlTree/SerializedMmlVisitor';\nimport { CHTMLWrapperFactory } from 'mathjax-full/js/output/chtml/WrapperFactory';\nimport { CHTMLmspace } from 'mathjax-full/js/output/chtml/Wrappers/mspace';\n\nconst visitor = new SerializedMmlVisitor();\nconst toMMl = node => visitor.visitTree(node);\n\nconst log = debug('pie-lib:math-rendering');\n\nconst NEWLINE_BLOCK_REGEX = /\\\\embed\\{newLine\\}\\[\\]/g;\nconst NEWLINE_LATEX = '\\\\newline ';\n\nconst getGlobal = () => {\n const key = `${pkg.name}@${pkg.version.split('.')[0]}`;\n\n if (typeof window !== 'undefined') {\n if (!window[key]) {\n window[key] = {};\n }\n return window[key];\n } else {\n return {};\n }\n};\n\n/** Add temporary support for a global singleDollar override\n * <code>\n * // This will enable single dollar rendering\n * window.pie = window.pie || {};\n * window.pie.mathRendering = {useSingleDollar: true };\n * </code>\n */\nconst defaultOpts = () => getGlobal().opts || {};\n\nexport const fixMathElement = element => {\n let property = 'innerText';\n\n if (element.textContent) {\n property = 'textContent';\n }\n\n if (element[property]) {\n element[property] = wrapMath(unWrapMath(element[property]).unwrapped);\n // because mathquill doesn't understand line breaks, sometimes we end up with custom elements on prompts/rationale/etc.\n // we need to replace the custom embedded elements with valid latex that Mathjax can understand\n element[property] = element[property].replace(NEWLINE_BLOCK_REGEX, NEWLINE_LATEX);\n }\n};\n\nexport const fixMathElements = () => {\n const mathElements = document.querySelectorAll('[data-latex]');\n\n mathElements.forEach(item => fixMathElement(item));\n};\n\nconst adjustMathMLStyle = () => {\n const nodes = document.querySelectorAll('math');\n nodes.forEach(node => node.setAttribute('displaystyle', 'true'));\n};\n\nconst bootstrap = opts => {\n if (typeof window === 'undefined') {\n return { Typeset: () => ({}) };\n }\n\n opts = opts || defaultOpts();\n\n if (opts.useSingleDollar) {\n // eslint-disable-next-line\n console.warn('[math-rendering] using $ is not advisable, please use $$..$$ or \\\\(...\\\\)');\n }\n\n const packages = AllPackages.filter(name => name !== 'bussproofs'); // Bussproofs needs an output jax\n\n // The autoload extension predefines all the macros from the extensions that haven't been loaded already\n // so that they automatically load the needed extension when they are first used\n packages.push('autoload');\n\n const macros = {\n parallelogram: '\\\\lower.2em{\\\\Huge\\\\unicode{x25B1}}',\n overarc: '\\\\overparen',\n napprox: '\\\\not\\\\approx',\n longdiv: '\\\\enclose{longdiv}'\n };\n\n const texConfig = opts.useSingleDollar\n ? {\n loader: {\n require: require\n },\n packages,\n macros,\n inlineMath: [\n ['$', '$'],\n ['\\\\(', '\\\\)']\n ],\n displayMath: [\n ['$$', '$$'],\n ['\\\\[', '\\\\]']\n ],\n processEscapes: true\n }\n : {\n packages,\n macros\n };\n\n const mmlConfig = {\n parseAs: 'html',\n forceReparse: false,\n parseError: function(node) {\n // function to process parsing errors\n console.log('error:', node);\n this.error(this.adaptor.textContent(node).replace(/\\n.*/g, ''));\n }\n };\n\n const fontURL = `https://unpkg.com/mathjax-full@${mathjax.version}/ts/output/chtml/fonts/tex-woff-v2`;\n const htmlConfig = {\n fontURL,\n\n wrapperFactory: new CHTMLWrapperFactory({\n ...CHTMLWrapperFactory.defaultNodes,\n ...chtmlNodes\n })\n };\n\n const mml = new MathML(mmlConfig);\n console.log([new TeX(texConfig), mml]);\n\n const customMmlFactory = new MmlFactory({\n ...MmlFactory.defaultNodes,\n ...mmlNodes\n });\n\n const html = mathjax.document(document, {\n compileError: (mj, math, err) => {\n console.log('bad math?:', math);\n console.error(err);\n },\n typesetError: function(doc, math, err) {\n console.log('typeset error');\n console.error(err);\n doc.typesetError(math, err);\n },\n\n InputJax: [new TeX(texConfig), mml],\n OutputJax: new CHTML(htmlConfig)\n });\n\n // Note: we must set this *after* mathjax.document (no idea why)\n mml.setMmlFactory(customMmlFactory);\n\n return {\n version: mathjax.version,\n html: html,\n Typeset: function(...elements) {\n const updatedDocument = this.html\n .findMath(elements.length ? { elements } : {})\n .compile()\n .getMetrics()\n .typeset()\n .updateDocument();\n\n try {\n const list = updatedDocument.math.list;\n\n for (let item = list.next; typeof item.data !== 'symbol'; item = item.next) {\n const mathMl = toMMl(item.data.root);\n const parsedMathMl = mathMl.replaceAll('\\n', '');\n\n item.data.typesetRoot.setAttribute('data-mathml', parsedMathMl);\n }\n } catch (e) {\n console.error(e.toString());\n }\n\n updatedDocument.clear();\n }\n };\n};\n\nconst renderMath = (el, renderOpts) => {\n //TODO: remove this - has nothing to do with math-rendering (it's from editable-html)\n fixMathElements();\n adjustMathMLStyle();\n\n if (!getGlobal().instance) {\n getGlobal().instance = bootstrap(renderOpts);\n }\n\n if (!el) {\n log('el is undefined');\n return;\n }\n\n if (el instanceof Element) {\n getGlobal().instance.Typeset(el);\n } else if (el.length) {\n const arr = Array.from(el);\n getGlobal().instance.Typeset(...arr);\n }\n};\n\n/**\n * This style is added to overried default styling of mjx-mspace Mathjax tag\n * In mathjax src code \\newline latex gets parsed to <mjx-mspace></mjx-mspace>,\n * but has the default style\n * 'mjx-mspace': {\n \"display\": 'in-line',\n \"text-align\": 'left'\n} which prevents it from showing as a newline value\n */\nCHTMLmspace.styles = {\n 'mjx-mspace': {\n display: 'block',\n 'text-align': 'center',\n height: '5px'\n }\n};\n\nexport default renderMath;\n"],"mappings":";;;;;;;AAAA;;AACA;;AACA;;AAEA;;AACA;;AACA;;AACA;;AAMA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;;;;;;;;;;;;;;;;;;;;;;;AAXA,IAAI,OAAOA,MAAP,KAAkB,WAAtB,EAAmC;EACjC,IAAAC,yBAAA,EAAoB,IAAAC,8BAAA,GAApB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1
+ {"version":3,"file":"render-math.js","names":["window","RegisterHTMLHandler","browserAdaptor","visitor","SerializedMmlVisitor","toMMl","node","visitTree","log","debug","NEWLINE_BLOCK_REGEX","NEWLINE_LATEX","getGlobal","key","pkg","name","version","split","defaultOpts","opts","fixMathElement","element","dataset","mathHandled","property","textContent","wrapMath","unWrapMath","unwrapped","replace","fixMathElements","mathElements","document","querySelectorAll","forEach","item","adjustMathMLStyle","nodes","setAttribute","bootstrap","Typeset","useSingleDollar","console","warn","packages","AllPackages","filter","push","macros","parallelogram","overarc","napprox","longdiv","texConfig","inlineMath","processEscapes","mmlConfig","parseError","error","adaptor","fontURL","mathjax","htmlConfig","wrapperFactory","CHTMLWrapperFactory","defaultNodes","chtmlNodes","mml","MathML","customMmlFactory","MmlFactory","mmlNodes","html","compileError","mj","math","err","typesetError","doc","InputJax","TeX","OutputJax","CHTML","setMmlFactory","elements","updatedDocument","findMath","length","compile","getMetrics","typeset","updateDocument","list","next","data","mathMl","root","parsedMathMl","replaceAll","typesetRoot","e","toString","clear","renderMath","el","renderOpts","instance","Element","arr","Array","from","CHTMLmspace","styles","display","height"],"sources":["../src/render-math.js"],"sourcesContent":["import { mathjax } from 'mathjax-full/js/mathjax';\nimport { MathML } from 'mathjax-full/js/input/mathml';\nimport { TeX } from 'mathjax-full/js/input/tex';\n\nimport { CHTML } from 'mathjax-full/js/output/chtml';\nimport { RegisterHTMLHandler } from 'mathjax-full/js/handlers/html';\nimport { browserAdaptor } from 'mathjax-full/js/adaptors/browserAdaptor';\nimport { AllPackages } from 'mathjax-full/js/input/tex/AllPackages';\n\nif (typeof window !== 'undefined') {\n RegisterHTMLHandler(browserAdaptor());\n}\n\nimport pkg from '../package.json';\nimport { mmlNodes, chtmlNodes } from './mstack';\nimport debug from 'debug';\nimport { wrapMath, unWrapMath } from './normalization';\nimport { MmlFactory } from 'mathjax-full/js/core/MmlTree/MmlFactory';\nimport { SerializedMmlVisitor } from 'mathjax-full/js/core/MmlTree/SerializedMmlVisitor';\nimport { CHTMLWrapperFactory } from 'mathjax-full/js/output/chtml/WrapperFactory';\nimport { CHTMLmspace } from 'mathjax-full/js/output/chtml/Wrappers/mspace';\n\nconst visitor = new SerializedMmlVisitor();\nconst toMMl = node => visitor.visitTree(node);\n\nconst log = debug('pie-lib:math-rendering');\n\nconst NEWLINE_BLOCK_REGEX = /\\\\embed\\{newLine\\}\\[\\]/g;\nconst NEWLINE_LATEX = '\\\\newline ';\n\nconst getGlobal = () => {\n const key = `${pkg.name}@${pkg.version.split('.')[0]}`;\n\n if (typeof window !== 'undefined') {\n if (!window[key]) {\n window[key] = {};\n }\n return window[key];\n } else {\n return {};\n }\n};\n\n/** Add temporary support for a global singleDollar override\n * <code>\n * // This will enable single dollar rendering\n * window.pie = window.pie || {};\n * window.pie.mathRendering = {useSingleDollar: true };\n * </code>\n */\nconst defaultOpts = () => getGlobal().opts || {};\n\nexport const fixMathElement = element => {\n if (element.dataset.mathHandled) {\n return;\n }\n\n let property = 'innerText';\n\n if (element.textContent) {\n property = 'textContent';\n }\n\n if (element[property]) {\n element[property] = wrapMath(unWrapMath(element[property]).unwrapped);\n // because mathquill doesn't understand line breaks, sometimes we end up with custom elements on prompts/rationale/etc.\n // we need to replace the custom embedded elements with valid latex that Mathjax can understand\n element[property] = element[property].replace(NEWLINE_BLOCK_REGEX, NEWLINE_LATEX);\n element.dataset.mathHandled = true;\n }\n};\n\nexport const fixMathElements = () => {\n const mathElements = document.querySelectorAll('[data-latex]');\n\n mathElements.forEach(item => fixMathElement(item));\n};\n\nconst adjustMathMLStyle = () => {\n const nodes = document.querySelectorAll('math');\n nodes.forEach(node => node.setAttribute('displaystyle', 'true'));\n};\n\nconst bootstrap = opts => {\n if (typeof window === 'undefined') {\n return { Typeset: () => ({}) };\n }\n\n opts = opts || defaultOpts();\n\n if (opts.useSingleDollar) {\n // eslint-disable-next-line\n console.warn('[math-rendering] using $ is not advisable, please use $$..$$ or \\\\(...\\\\)');\n }\n\n const packages = AllPackages.filter(name => name !== 'bussproofs'); // Bussproofs needs an output jax\n\n // The autoload extension predefines all the macros from the extensions that haven't been loaded already\n // so that they automatically load the needed extension when they are first used\n packages.push('autoload');\n\n const macros = {\n parallelogram: '\\\\lower.2em{\\\\Huge\\\\unicode{x25B1}}',\n overarc: '\\\\overparen',\n napprox: '\\\\not\\\\approx',\n longdiv: '\\\\enclose{longdiv}'\n };\n\n const texConfig = opts.useSingleDollar\n ? {\n packages,\n macros,\n inlineMath: [\n ['$', '$'],\n ['\\\\(', '\\\\)']\n ],\n processEscapes: true\n }\n : {\n packages,\n macros\n };\n\n const mmlConfig = {\n parseError: function(node) {\n // function to process parsing errors\n console.log('error:', node);\n this.error(this.adaptor.textContent(node).replace(/\\n.*/g, ''));\n }\n };\n\n const fontURL = `https://unpkg.com/mathjax-full@${mathjax.version}/ts/output/chtml/fonts/tex-woff-v2`;\n const htmlConfig = {\n fontURL,\n\n wrapperFactory: new CHTMLWrapperFactory({\n ...CHTMLWrapperFactory.defaultNodes,\n ...chtmlNodes\n })\n };\n\n const mml = new MathML(mmlConfig);\n\n const customMmlFactory = new MmlFactory({\n ...MmlFactory.defaultNodes,\n ...mmlNodes\n });\n\n const html = mathjax.document(document, {\n compileError: (mj, math, err) => {\n console.log('bad math?:', math);\n console.error(err);\n },\n typesetError: function(doc, math, err) {\n console.log('typeset error');\n console.error(err);\n doc.typesetError(math, err);\n },\n\n InputJax: [new TeX(texConfig), mml],\n OutputJax: new CHTML(htmlConfig)\n });\n\n // Note: we must set this *after* mathjax.document (no idea why)\n mml.setMmlFactory(customMmlFactory);\n\n return {\n version: mathjax.version,\n html: html,\n Typeset: function(...elements) {\n const updatedDocument = this.html\n .findMath(elements.length ? { elements } : {})\n .compile()\n .getMetrics()\n .typeset()\n .updateDocument();\n\n try {\n const list = updatedDocument.math.list;\n\n for (let item = list.next; typeof item.data !== 'symbol'; item = item.next) {\n const mathMl = toMMl(item.data.root);\n const parsedMathMl = mathMl.replaceAll('\\n', '');\n\n item.data.typesetRoot.setAttribute('data-mathml', parsedMathMl);\n }\n } catch (e) {\n console.error(e.toString());\n }\n\n updatedDocument.clear();\n }\n };\n};\n\nconst renderMath = (el, renderOpts) => {\n //TODO: remove this - has nothing to do with math-rendering (it's from editable-html)\n fixMathElements();\n adjustMathMLStyle();\n\n if (!getGlobal().instance) {\n getGlobal().instance = bootstrap(renderOpts);\n }\n\n if (!el) {\n log('el is undefined');\n return;\n }\n\n if (el instanceof Element) {\n getGlobal().instance.Typeset(el);\n } else if (el.length) {\n const arr = Array.from(el);\n getGlobal().instance.Typeset(...arr);\n }\n};\n\n/**\n * This style is added to overried default styling of mjx-mspace Mathjax tag\n * In mathjax src code \\newline latex gets parsed to <mjx-mspace></mjx-mspace>,\n * but has the default style\n * 'mjx-mspace': {\n \"display\": 'in-line',\n \"text-align\": 'left'\n} which prevents it from showing as a newline value\n */\nCHTMLmspace.styles = {\n 'mjx-mspace': {\n display: 'block',\n 'text-align': 'center',\n height: '5px'\n }\n};\n\nexport default renderMath;\n"],"mappings":";;;;;;;;;;;;;;;AAAA;;AACA;;AACA;;AAEA;;AACA;;AACA;;AACA;;AAMA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;;;;;AAXA,IAAI,OAAOA,MAAP,KAAkB,WAAtB,EAAmC;EACjC,IAAAC,yBAAA,EAAoB,IAAAC,8BAAA,GAApB;AACD;;AAWD,IAAMC,OAAO,GAAG,IAAIC,0CAAJ,EAAhB;;AACA,IAAMC,KAAK,GAAG,SAARA,KAAQ,CAAAC,IAAI;EAAA,OAAIH,OAAO,CAACI,SAAR,CAAkBD,IAAlB,CAAJ;AAAA,CAAlB;;AAEA,IAAME,GAAG,GAAG,IAAAC,iBAAA,EAAM,wBAAN,CAAZ;AAEA,IAAMC,mBAAmB,GAAG,yBAA5B;AACA,IAAMC,aAAa,GAAG,YAAtB;;AAEA,IAAMC,SAAS,GAAG,SAAZA,SAAY,GAAM;EACtB,IAAMC,GAAG,aAAMC,mBAAA,CAAI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,SAAS,GAAG8F,QAAjB,EAA2B;IACzB9F,SAAS,GAAG8F,QAAZ,GAAuBnE,SAAS,CAACkE,UAAD,CAAhC;EACD;;EAED,IAAI,CAACD,EAAL,EAAS;IACPhG,GAAG,CAAC,iBAAD,CAAH;IACA;EACD;;EAED,IAAIgG,EAAE,YAAYG,OAAlB,EAA2B;IACzB/F,SAAS,GAAG8F,QAAZ,CAAqBlE,OAArB,CAA6BgE,EAA7B;EACD,CAFD,MAEO,IAAIA,EAAE,CAACjB,MAAP,EAAe;IAAA;;IACpB,IAAMqB,GAAG,GAAGC,KAAK,CAACC,IAAN,CAAWN,EAAX,CAAZ;;IACA,uBAAA5F,SAAS,GAAG8F,QAAZ,EAAqBlE,OAArB,gEAAgCoE,GAAhC;EACD;AACF,CApBD;AAsBA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AACAG,mBAAA,CAAYC,MAAZ,GAAqB;EACnB,cAAc;IACZC,OAAO,EAAE,OADG;IAEZ,cAAc,QAFF;IAGZC,MAAM,EAAE;EAHI;AADK,CAArB;eAQeX,U"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pie-lib/math-rendering",
3
- "version": "2.3.10-next.306+d4c12e9b",
3
+ "version": "2.3.10-next.414+e2932997",
4
4
  "description": "math rendering utilities",
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -14,6 +14,6 @@
14
14
  "lodash": "^4.17.11",
15
15
  "mathjax-full": "3.2.0"
16
16
  },
17
- "gitHead": "d4c12e9bebddc8c13f218c3fc301d02ea8e98b8c",
17
+ "gitHead": "e2932997d4237f56981af5ca83cbc68447e2feb6",
18
18
  "scripts": {}
19
19
  }
@@ -211,5 +211,8 @@ CHTMLmstack.styles = {
211
211
  'mjx-mstack > table > tr > .mjx-line': {
212
212
  padding: 0,
213
213
  'border-top': 'solid 1px black'
214
+ },
215
+ '.TEX-A': {
216
+ 'font-family': 'MJXZERO, MJXTEX !important'
214
217
  }
215
218
  };
@@ -51,6 +51,10 @@ const getGlobal = () => {
51
51
  const defaultOpts = () => getGlobal().opts || {};
52
52
 
53
53
  export const fixMathElement = element => {
54
+ if (element.dataset.mathHandled) {
55
+ return;
56
+ }
57
+
54
58
  let property = 'innerText';
55
59
 
56
60
  if (element.textContent) {
@@ -62,6 +66,7 @@ export const fixMathElement = element => {
62
66
  // because mathquill doesn't understand line breaks, sometimes we end up with custom elements on prompts/rationale/etc.
63
67
  // we need to replace the custom embedded elements with valid latex that Mathjax can understand
64
68
  element[property] = element[property].replace(NEWLINE_BLOCK_REGEX, NEWLINE_LATEX);
69
+ element.dataset.mathHandled = true;
65
70
  }
66
71
  };
67
72
 
@@ -103,29 +108,20 @@ const bootstrap = opts => {
103
108
 
104
109
  const texConfig = opts.useSingleDollar
105
110
  ? {
106
- loader: {
107
- require: require
108
- },
109
- packages,
110
- macros,
111
- inlineMath: [
112
- ['$', '$'],
113
- ['\\(', '\\)']
114
- ],
115
- displayMath: [
116
- ['$$', '$$'],
117
- ['\\[', '\\]']
118
- ],
119
- processEscapes: true
120
- }
111
+ packages,
112
+ macros,
113
+ inlineMath: [
114
+ ['$', '$'],
115
+ ['\\(', '\\)']
116
+ ],
117
+ processEscapes: true
118
+ }
121
119
  : {
122
- packages,
123
- macros
124
- };
120
+ packages,
121
+ macros
122
+ };
125
123
 
126
124
  const mmlConfig = {
127
- parseAs: 'html',
128
- forceReparse: false,
129
125
  parseError: function(node) {
130
126
  // function to process parsing errors
131
127
  console.log('error:', node);
@@ -144,7 +140,6 @@ const bootstrap = opts => {
144
140
  };
145
141
 
146
142
  const mml = new MathML(mmlConfig);
147
- console.log([new TeX(texConfig), mml]);
148
143
 
149
144
  const customMmlFactory = new MmlFactory({
150
145
  ...MmlFactory.defaultNodes,