@pie-element/ebsr 7.0.22 → 7.0.24-next.2
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 +0 -16
- package/configure/CHANGELOG.md +0 -16
- package/configure/lib/main.js +6 -4
- package/configure/lib/main.js.map +1 -1
- package/configure/node_modules/@pie-element/multiple-choice/CHANGELOG.json +1972 -0
- package/configure/node_modules/@pie-element/multiple-choice/CHANGELOG.md +1793 -0
- package/{LICENSE.md → configure/node_modules/@pie-element/multiple-choice/LICENSE.md} +0 -0
- package/configure/node_modules/@pie-element/multiple-choice/PRINT.md +35 -0
- package/configure/node_modules/@pie-element/multiple-choice/README.md +56 -0
- package/configure/node_modules/@pie-element/multiple-choice/choice.png +0 -0
- package/configure/node_modules/@pie-element/multiple-choice/configure/CHANGELOG.json +1387 -0
- package/configure/node_modules/@pie-element/multiple-choice/configure/CHANGELOG.md +1334 -0
- package/configure/node_modules/@pie-element/multiple-choice/configure/lib/defaults.js +104 -0
- package/configure/node_modules/@pie-element/multiple-choice/configure/lib/defaults.js.map +1 -0
- package/configure/node_modules/@pie-element/multiple-choice/configure/lib/index.js +198 -0
- package/configure/node_modules/@pie-element/multiple-choice/configure/lib/index.js.map +1 -0
- package/configure/node_modules/@pie-element/multiple-choice/configure/lib/main.js +599 -0
- package/configure/node_modules/@pie-element/multiple-choice/configure/lib/main.js.map +1 -0
- package/configure/node_modules/@pie-element/multiple-choice/configure/lib/utils.js +18 -0
- package/configure/node_modules/@pie-element/multiple-choice/configure/lib/utils.js.map +1 -0
- package/configure/node_modules/@pie-element/multiple-choice/configure/package.json +20 -0
- package/configure/node_modules/@pie-element/multiple-choice/controller/CHANGELOG.json +527 -0
- package/configure/node_modules/@pie-element/multiple-choice/controller/CHANGELOG.md +768 -0
- package/configure/node_modules/@pie-element/multiple-choice/controller/lib/defaults.js +18 -0
- package/configure/node_modules/@pie-element/multiple-choice/controller/lib/defaults.js.map +1 -0
- package/configure/node_modules/@pie-element/multiple-choice/controller/lib/index.js +305 -0
- package/configure/node_modules/@pie-element/multiple-choice/controller/lib/index.js.map +1 -0
- package/configure/node_modules/@pie-element/multiple-choice/controller/lib/utils.js +36 -0
- package/configure/node_modules/@pie-element/multiple-choice/controller/lib/utils.js.map +1 -0
- package/configure/node_modules/@pie-element/multiple-choice/controller/package.json +15 -0
- package/configure/node_modules/@pie-element/multiple-choice/docs/config-schema.json +353 -0
- package/configure/node_modules/@pie-element/multiple-choice/docs/config-schema.json.md +277 -0
- package/configure/node_modules/@pie-element/multiple-choice/docs/demo/config.js +8 -0
- package/configure/node_modules/@pie-element/multiple-choice/docs/demo/generate.js +52 -0
- package/configure/node_modules/@pie-element/multiple-choice/docs/demo/index.html +1 -0
- package/configure/node_modules/@pie-element/multiple-choice/docs/demo/session.js +7 -0
- package/configure/node_modules/@pie-element/multiple-choice/docs/pie-schema.json +338 -0
- package/configure/node_modules/@pie-element/multiple-choice/docs/pie-schema.json.md +274 -0
- package/configure/node_modules/@pie-element/multiple-choice/lib/choice-input.js +298 -0
- package/configure/node_modules/@pie-element/multiple-choice/lib/choice-input.js.map +1 -0
- package/configure/node_modules/@pie-element/multiple-choice/lib/choice.js +157 -0
- package/configure/node_modules/@pie-element/multiple-choice/lib/choice.js.map +1 -0
- package/configure/node_modules/@pie-element/multiple-choice/lib/feedback-tick.js +174 -0
- package/configure/node_modules/@pie-element/multiple-choice/lib/feedback-tick.js.map +1 -0
- package/configure/node_modules/@pie-element/multiple-choice/lib/index.js +151 -0
- package/configure/node_modules/@pie-element/multiple-choice/lib/index.js.map +1 -0
- package/configure/node_modules/@pie-element/multiple-choice/lib/main.js +97 -0
- package/configure/node_modules/@pie-element/multiple-choice/lib/main.js.map +1 -0
- package/configure/node_modules/@pie-element/multiple-choice/lib/multiple-choice.js +254 -0
- package/configure/node_modules/@pie-element/multiple-choice/lib/multiple-choice.js.map +1 -0
- package/configure/node_modules/@pie-element/multiple-choice/lib/print.js +129 -0
- package/configure/node_modules/@pie-element/multiple-choice/lib/print.js.map +1 -0
- package/configure/node_modules/@pie-element/multiple-choice/lib/session-updater.js +35 -0
- package/configure/node_modules/@pie-element/multiple-choice/lib/session-updater.js.map +1 -0
- package/configure/node_modules/@pie-element/multiple-choice/module/configure.js +843 -0
- package/{module → configure/node_modules/@pie-element/multiple-choice/module}/controller.js +17304 -17374
- package/configure/node_modules/@pie-element/multiple-choice/module/demo.js +77 -0
- package/{module → configure/node_modules/@pie-element/multiple-choice/module}/element.js +42 -171
- package/{module → configure/node_modules/@pie-element/multiple-choice/module}/index.html +1 -1
- package/{module → configure/node_modules/@pie-element/multiple-choice/module}/manifest.json +4 -4
- package/{module → configure/node_modules/@pie-element/multiple-choice/module}/print-demo.js +46 -46
- package/{module → configure/node_modules/@pie-element/multiple-choice/module}/print.html +1 -1
- package/{module → configure/node_modules/@pie-element/multiple-choice/module}/print.js +70 -259
- package/configure/node_modules/@pie-element/multiple-choice/package.json +34 -0
- package/configure/node_modules/@pie-lib/math-rendering/CHANGELOG.json +672 -0
- package/configure/node_modules/@pie-lib/math-rendering/CHANGELOG.md +427 -0
- package/configure/node_modules/@pie-lib/math-rendering/LICENSE.md +5 -0
- package/configure/node_modules/@pie-lib/math-rendering/lib/index.js +30 -0
- package/configure/node_modules/@pie-lib/math-rendering/lib/index.js.map +1 -0
- package/configure/node_modules/@pie-lib/math-rendering/lib/mstack/chtml.js +316 -0
- package/configure/node_modules/@pie-lib/math-rendering/lib/mstack/chtml.js.map +1 -0
- package/configure/node_modules/@pie-lib/math-rendering/lib/mstack/index.js +23 -0
- package/configure/node_modules/@pie-lib/math-rendering/lib/mstack/index.js.map +1 -0
- package/configure/node_modules/@pie-lib/math-rendering/lib/mstack/mml.js +123 -0
- package/configure/node_modules/@pie-lib/math-rendering/lib/mstack/mml.js.map +1 -0
- package/configure/node_modules/@pie-lib/math-rendering/lib/normalization.js +103 -0
- package/configure/node_modules/@pie-lib/math-rendering/lib/normalization.js.map +1 -0
- package/configure/node_modules/@pie-lib/math-rendering/lib/render-math.js +275 -0
- package/configure/node_modules/@pie-lib/math-rendering/lib/render-math.js.map +1 -0
- package/configure/node_modules/@pie-lib/math-rendering/package.json +19 -0
- package/configure/node_modules/@pie-lib/math-rendering/playground/demo.html +872 -0
- package/configure/node_modules/@pie-lib/math-rendering/playground/demo.js +108 -0
- package/configure/node_modules/@pie-lib/math-rendering/playground/main.html +156 -0
- package/configure/node_modules/@pie-lib/math-rendering/playground/main.js +16 -0
- package/configure/node_modules/@pie-lib/math-rendering/playground/webpack.config.js +29 -0
- package/configure/node_modules/@pie-lib/math-rendering/src/index.js +4 -0
- package/configure/node_modules/@pie-lib/math-rendering/src/mstack/chtml.js +215 -0
- package/configure/node_modules/@pie-lib/math-rendering/src/mstack/index.js +13 -0
- package/configure/node_modules/@pie-lib/math-rendering/src/mstack/mml.js +24 -0
- package/configure/node_modules/@pie-lib/math-rendering/src/normalization.js +69 -0
- package/configure/node_modules/@pie-lib/math-rendering/src/render-math.js +234 -0
- package/configure/node_modules/@pie-lib/render-ui/CHANGELOG.json +937 -0
- package/configure/node_modules/@pie-lib/render-ui/CHANGELOG.md +602 -0
- package/configure/node_modules/@pie-lib/render-ui/LICENSE.md +5 -0
- package/configure/node_modules/@pie-lib/render-ui/README.md +33 -0
- package/configure/node_modules/@pie-lib/render-ui/lib/collapsible/index.js +146 -0
- package/configure/node_modules/@pie-lib/render-ui/lib/collapsible/index.js.map +1 -0
- package/configure/node_modules/@pie-lib/render-ui/lib/color.js +134 -0
- package/configure/node_modules/@pie-lib/render-ui/lib/color.js.map +1 -0
- package/configure/node_modules/@pie-lib/render-ui/lib/feedback.js +160 -0
- package/configure/node_modules/@pie-lib/render-ui/lib/feedback.js.map +1 -0
- package/configure/node_modules/@pie-lib/render-ui/lib/has-text.js +24 -0
- package/configure/node_modules/@pie-lib/render-ui/lib/has-text.js.map +1 -0
- package/configure/node_modules/@pie-lib/render-ui/lib/html-and-math.js +102 -0
- package/configure/node_modules/@pie-lib/render-ui/lib/html-and-math.js.map +1 -0
- package/configure/node_modules/@pie-lib/render-ui/lib/index.js +104 -0
- package/configure/node_modules/@pie-lib/render-ui/lib/index.js.map +1 -0
- package/configure/node_modules/@pie-lib/render-ui/lib/input-container.js +60 -0
- package/configure/node_modules/@pie-lib/render-ui/lib/input-container.js.map +1 -0
- package/configure/node_modules/@pie-lib/render-ui/lib/preview-layout.js +133 -0
- package/configure/node_modules/@pie-lib/render-ui/lib/preview-layout.js.map +1 -0
- package/configure/node_modules/@pie-lib/render-ui/lib/preview-prompt.js +162 -0
- package/configure/node_modules/@pie-lib/render-ui/lib/preview-prompt.js.map +1 -0
- package/configure/node_modules/@pie-lib/render-ui/lib/purpose.js +28 -0
- package/configure/node_modules/@pie-lib/render-ui/lib/purpose.js.map +1 -0
- package/configure/node_modules/@pie-lib/render-ui/lib/readable.js +28 -0
- package/configure/node_modules/@pie-lib/render-ui/lib/readable.js.map +1 -0
- package/configure/node_modules/@pie-lib/render-ui/lib/response-indicators.js +160 -0
- package/configure/node_modules/@pie-lib/render-ui/lib/response-indicators.js.map +1 -0
- package/configure/node_modules/@pie-lib/render-ui/lib/withUndoReset.js +206 -0
- package/configure/node_modules/@pie-lib/render-ui/lib/withUndoReset.js.map +1 -0
- package/configure/node_modules/@pie-lib/render-ui/package.json +30 -0
- package/configure/node_modules/@pie-lib/render-ui/src/collapsible/index.jsx +68 -0
- package/configure/node_modules/@pie-lib/render-ui/src/color.js +48 -0
- package/configure/node_modules/@pie-lib/render-ui/src/feedback.jsx +100 -0
- package/configure/node_modules/@pie-lib/render-ui/src/has-text.js +14 -0
- package/configure/node_modules/@pie-lib/render-ui/src/html-and-math.js +40 -0
- package/configure/node_modules/@pie-lib/render-ui/src/index.js +27 -0
- package/configure/node_modules/@pie-lib/render-ui/src/input-container.jsx +41 -0
- package/configure/node_modules/@pie-lib/render-ui/src/preview-layout.jsx +77 -0
- package/configure/node_modules/@pie-lib/render-ui/src/preview-prompt.jsx +90 -0
- package/configure/node_modules/@pie-lib/render-ui/src/purpose.jsx +19 -0
- package/configure/node_modules/@pie-lib/render-ui/src/readable.jsx +19 -0
- package/configure/node_modules/@pie-lib/render-ui/src/response-indicators.jsx +89 -0
- package/configure/node_modules/@pie-lib/render-ui/src/withUndoReset.jsx +118 -0
- package/configure/package.json +3 -3
- package/configure/src/__tests__/index.test.js +4 -2
- package/configure/src/main.jsx +8 -3
- package/controller/lib/index.js +79 -3
- package/controller/lib/index.js.map +1 -1
- package/controller/src/index.js +55 -0
- package/package.json +3 -3
- package/module/configure.js +0 -472
- package/module/demo.js +0 -77
|
@@ -0,0 +1,275 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.fixMathElements = exports.fixMathElement = exports["default"] = void 0;
|
|
7
|
+
|
|
8
|
+
var _mathjax = require("mathjax-full/js/mathjax");
|
|
9
|
+
|
|
10
|
+
var _mathml = require("mathjax-full/js/input/mathml");
|
|
11
|
+
|
|
12
|
+
var _tex = require("mathjax-full/js/input/tex");
|
|
13
|
+
|
|
14
|
+
var _chtml = require("mathjax-full/js/output/chtml");
|
|
15
|
+
|
|
16
|
+
var _html = require("mathjax-full/js/handlers/html");
|
|
17
|
+
|
|
18
|
+
var _browserAdaptor = require("mathjax-full/js/adaptors/browserAdaptor");
|
|
19
|
+
|
|
20
|
+
var _AllPackages = require("mathjax-full/js/input/tex/AllPackages");
|
|
21
|
+
|
|
22
|
+
var _package = _interopRequireDefault(require("../package.json"));
|
|
23
|
+
|
|
24
|
+
var _mstack = require("./mstack");
|
|
25
|
+
|
|
26
|
+
var _debug = _interopRequireDefault(require("debug"));
|
|
27
|
+
|
|
28
|
+
var _normalization = require("./normalization");
|
|
29
|
+
|
|
30
|
+
var _MmlFactory = require("mathjax-full/js/core/MmlTree/MmlFactory");
|
|
31
|
+
|
|
32
|
+
var _SerializedMmlVisitor = require("mathjax-full/js/core/MmlTree/SerializedMmlVisitor");
|
|
33
|
+
|
|
34
|
+
var _WrapperFactory = require("mathjax-full/js/output/chtml/WrapperFactory");
|
|
35
|
+
|
|
36
|
+
var _mspace = require("mathjax-full/js/output/chtml/Wrappers/mspace");
|
|
37
|
+
|
|
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
|
+
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
|
+
|
|
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; }
|
|
59
|
+
|
|
60
|
+
if (typeof window !== 'undefined') {
|
|
61
|
+
(0, _html.RegisterHTMLHandler)((0, _browserAdaptor.browserAdaptor)());
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
var visitor = new _SerializedMmlVisitor.SerializedMmlVisitor();
|
|
65
|
+
|
|
66
|
+
var toMMl = function toMMl(node) {
|
|
67
|
+
return visitor.visitTree(node);
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
var log = (0, _debug["default"])('pie-lib:math-rendering');
|
|
71
|
+
var NEWLINE_BLOCK_REGEX = /\\embed\{newLine\}\[\]/g;
|
|
72
|
+
var NEWLINE_LATEX = '\\newline ';
|
|
73
|
+
|
|
74
|
+
var getGlobal = function getGlobal() {
|
|
75
|
+
var key = "".concat(_package["default"].name, "@").concat(_package["default"].version.split('.')[0]);
|
|
76
|
+
|
|
77
|
+
if (typeof window !== 'undefined') {
|
|
78
|
+
if (!window[key]) {
|
|
79
|
+
window[key] = {};
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
return window[key];
|
|
83
|
+
} else {
|
|
84
|
+
return {};
|
|
85
|
+
}
|
|
86
|
+
};
|
|
87
|
+
/** Add temporary support for a global singleDollar override
|
|
88
|
+
* <code>
|
|
89
|
+
* // This will enable single dollar rendering
|
|
90
|
+
* window.pie = window.pie || {};
|
|
91
|
+
* window.pie.mathRendering = {useSingleDollar: true };
|
|
92
|
+
* </code>
|
|
93
|
+
*/
|
|
94
|
+
|
|
95
|
+
|
|
96
|
+
var defaultOpts = function defaultOpts() {
|
|
97
|
+
return getGlobal().opts || {};
|
|
98
|
+
};
|
|
99
|
+
|
|
100
|
+
var fixMathElement = function fixMathElement(element) {
|
|
101
|
+
var property = 'innerText';
|
|
102
|
+
|
|
103
|
+
if (element.textContent) {
|
|
104
|
+
property = 'textContent';
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
if (element[property]) {
|
|
108
|
+
element[property] = (0, _normalization.wrapMath)((0, _normalization.unWrapMath)(element[property]).unwrapped); // because mathquill doesn't understand line breaks, sometimes we end up with custom elements on prompts/rationale/etc.
|
|
109
|
+
// we need to replace the custom embedded elements with valid latex that Mathjax can understand
|
|
110
|
+
|
|
111
|
+
element[property] = element[property].replace(NEWLINE_BLOCK_REGEX, NEWLINE_LATEX);
|
|
112
|
+
}
|
|
113
|
+
};
|
|
114
|
+
|
|
115
|
+
exports.fixMathElement = fixMathElement;
|
|
116
|
+
|
|
117
|
+
var fixMathElements = function fixMathElements() {
|
|
118
|
+
var mathElements = document.querySelectorAll('[data-latex]');
|
|
119
|
+
mathElements.forEach(function (item) {
|
|
120
|
+
return fixMathElement(item);
|
|
121
|
+
});
|
|
122
|
+
};
|
|
123
|
+
|
|
124
|
+
exports.fixMathElements = fixMathElements;
|
|
125
|
+
|
|
126
|
+
var bootstrap = function bootstrap(opts) {
|
|
127
|
+
if (typeof window === 'undefined') {
|
|
128
|
+
return {
|
|
129
|
+
Typeset: function Typeset() {
|
|
130
|
+
return {};
|
|
131
|
+
}
|
|
132
|
+
};
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
opts = opts || defaultOpts();
|
|
136
|
+
|
|
137
|
+
if (opts.useSingleDollar) {
|
|
138
|
+
// eslint-disable-next-line
|
|
139
|
+
console.warn('[math-rendering] using $ is not advisable, please use $$..$$ or \\(...\\)');
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
var packages = _AllPackages.AllPackages.filter(function (name) {
|
|
143
|
+
return name !== 'bussproofs';
|
|
144
|
+
}); // Bussproofs needs an output jax
|
|
145
|
+
// The autoload extension predefines all the macros from the extensions that haven't been loaded already
|
|
146
|
+
// so that they automatically load the needed extension when they are first used
|
|
147
|
+
|
|
148
|
+
|
|
149
|
+
packages.push('autoload');
|
|
150
|
+
var macros = {
|
|
151
|
+
parallelogram: "\\lower.2em{\\Huge\\unicode{x25B1}}",
|
|
152
|
+
overarc: '\\overparen',
|
|
153
|
+
napprox: '\\not\\approx',
|
|
154
|
+
longdiv: '\\enclose{longdiv}'
|
|
155
|
+
};
|
|
156
|
+
var texConfig = opts.useSingleDollar ? {
|
|
157
|
+
loader: {
|
|
158
|
+
require: require
|
|
159
|
+
},
|
|
160
|
+
packages: packages,
|
|
161
|
+
macros: macros,
|
|
162
|
+
inlineMath: [['$', '$'], ['\\(', '\\)']],
|
|
163
|
+
displayMath: [['$$', '$$'], ['\\[', '\\]']],
|
|
164
|
+
processEscapes: true
|
|
165
|
+
} : {
|
|
166
|
+
packages: packages,
|
|
167
|
+
macros: macros
|
|
168
|
+
};
|
|
169
|
+
var mmlConfig = {
|
|
170
|
+
parseAs: 'html',
|
|
171
|
+
forceReparse: false,
|
|
172
|
+
parseError: function parseError(node) {
|
|
173
|
+
// function to process parsing errors
|
|
174
|
+
console.log('error:', node);
|
|
175
|
+
this.error(this.adaptor.textContent(node).replace(/\n.*/g, ''));
|
|
176
|
+
}
|
|
177
|
+
};
|
|
178
|
+
var fontURL = "https://unpkg.com/mathjax-full@".concat(_mathjax.mathjax.version, "/ts/output/chtml/fonts/tex-woff-v2");
|
|
179
|
+
var htmlConfig = {
|
|
180
|
+
fontURL: fontURL,
|
|
181
|
+
wrapperFactory: new _WrapperFactory.CHTMLWrapperFactory(_objectSpread(_objectSpread({}, _WrapperFactory.CHTMLWrapperFactory.defaultNodes), _mstack.chtmlNodes))
|
|
182
|
+
};
|
|
183
|
+
var mml = new _mathml.MathML(mmlConfig);
|
|
184
|
+
console.log([new _tex.TeX(texConfig), mml]);
|
|
185
|
+
var customMmlFactory = new _MmlFactory.MmlFactory(_objectSpread(_objectSpread({}, _MmlFactory.MmlFactory.defaultNodes), _mstack.mmlNodes));
|
|
186
|
+
|
|
187
|
+
var html = _mathjax.mathjax.document(document, {
|
|
188
|
+
compileError: function compileError(mj, math, err) {
|
|
189
|
+
console.log('bad math?:', math);
|
|
190
|
+
console.error(err);
|
|
191
|
+
},
|
|
192
|
+
typesetError: function typesetError(doc, math, err) {
|
|
193
|
+
console.log('typeset error');
|
|
194
|
+
console.error(err);
|
|
195
|
+
doc.typesetError(math, err);
|
|
196
|
+
},
|
|
197
|
+
InputJax: [new _tex.TeX(texConfig), mml],
|
|
198
|
+
OutputJax: new _chtml.CHTML(htmlConfig)
|
|
199
|
+
}); // Note: we must set this *after* mathjax.document (no idea why)
|
|
200
|
+
|
|
201
|
+
|
|
202
|
+
mml.setMmlFactory(customMmlFactory);
|
|
203
|
+
return {
|
|
204
|
+
version: _mathjax.mathjax.version,
|
|
205
|
+
html: html,
|
|
206
|
+
Typeset: function Typeset() {
|
|
207
|
+
for (var _len = arguments.length, elements = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
208
|
+
elements[_key] = arguments[_key];
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
var updatedDocument = this.html.findMath(elements.length ? {
|
|
212
|
+
elements: elements
|
|
213
|
+
} : {}).compile().getMetrics().typeset().updateDocument();
|
|
214
|
+
|
|
215
|
+
try {
|
|
216
|
+
var list = updatedDocument.math.list;
|
|
217
|
+
|
|
218
|
+
for (var item = list.next; _typeof(item.data) !== 'symbol'; item = item.next) {
|
|
219
|
+
var mathMl = toMMl(item.data.root);
|
|
220
|
+
var parsedMathMl = mathMl.replaceAll('\n', '');
|
|
221
|
+
item.data.typesetRoot.setAttribute('data-mathml', parsedMathMl);
|
|
222
|
+
}
|
|
223
|
+
} catch (e) {
|
|
224
|
+
console.error(e.toString());
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
updatedDocument.clear();
|
|
228
|
+
}
|
|
229
|
+
};
|
|
230
|
+
};
|
|
231
|
+
|
|
232
|
+
var renderMath = function renderMath(el, renderOpts) {
|
|
233
|
+
//TODO: remove this - has nothing to do with math-rendering (it's from editable-html)
|
|
234
|
+
fixMathElements();
|
|
235
|
+
|
|
236
|
+
if (!getGlobal().instance) {
|
|
237
|
+
getGlobal().instance = bootstrap(renderOpts);
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
if (!el) {
|
|
241
|
+
log('el is undefined');
|
|
242
|
+
return;
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
if (el instanceof Element) {
|
|
246
|
+
getGlobal().instance.Typeset(el);
|
|
247
|
+
} else if (el.length) {
|
|
248
|
+
var _getGlobal$instance;
|
|
249
|
+
|
|
250
|
+
var arr = Array.from(el);
|
|
251
|
+
|
|
252
|
+
(_getGlobal$instance = getGlobal().instance).Typeset.apply(_getGlobal$instance, _toConsumableArray(arr));
|
|
253
|
+
}
|
|
254
|
+
};
|
|
255
|
+
/**
|
|
256
|
+
* This style is added to overried default styling of mjx-mspace Mathjax tag
|
|
257
|
+
* In mathjax src code \newline latex gets parsed to <mjx-mspace></mjx-mspace>,
|
|
258
|
+
* but has the default style
|
|
259
|
+
* 'mjx-mspace': {
|
|
260
|
+
"display": 'in-line',
|
|
261
|
+
"text-align": 'left'
|
|
262
|
+
} which prevents it from showing as a newline value
|
|
263
|
+
*/
|
|
264
|
+
|
|
265
|
+
|
|
266
|
+
_mspace.CHTMLmspace.styles = {
|
|
267
|
+
'mjx-mspace': {
|
|
268
|
+
display: 'block',
|
|
269
|
+
'text-align': 'center',
|
|
270
|
+
height: '5px'
|
|
271
|
+
}
|
|
272
|
+
};
|
|
273
|
+
var _default = renderMath;
|
|
274
|
+
exports["default"] = _default;
|
|
275
|
+
//# sourceMappingURL=render-math.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/render-math.js"],"names":["window","visitor","SerializedMmlVisitor","toMMl","node","visitTree","log","NEWLINE_BLOCK_REGEX","NEWLINE_LATEX","getGlobal","key","pkg","name","version","split","defaultOpts","opts","fixMathElement","element","property","textContent","unwrapped","replace","fixMathElements","mathElements","document","querySelectorAll","forEach","item","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","setAttribute","e","toString","clear","renderMath","el","renderOpts","instance","Element","arr","Array","from","CHTMLmspace","styles","display","height"],"mappings":";;;;;;;AAAA;;AACA;;AACA;;AAEA;;AACA;;AACA;;AACA;;AAMA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;;;;;;;;;;;;;;;;;;;;;;;AAXA,IAAI,OAAOA,MAAP,KAAkB,WAAtB,EAAmC;AACjC,iCAAoB,qCAApB;AACD;;AAWD,IAAMC,OAAO,GAAG,IAAIC,0CAAJ,EAAhB;;AACA,IAAMC,KAAK,GAAG,SAARA,KAAQ,CAAAC,IAAI;AAAA,SAAIH,OA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B,IAAlB,EAAwB,EAAxB,CAArB;AAEAjE,UAAAA,IAAI,CAAC6D,IAAL,CAAUK,WAAV,CAAsBC,YAAtB,CAAmC,aAAnC,EAAkDH,YAAlD;AACD;AACF,OATD,CASE,OAAOI,CAAP,EAAU;AACVhE,QAAAA,OAAO,CAACqB,KAAR,CAAc2C,CAAC,CAACC,QAAF,EAAd;AACD;;AAEDjB,MAAAA,eAAe,CAACkB,KAAhB;AACD;AAzBI,GAAP;AA2BD,CAxHD;;AA0HA,IAAMC,UAAU,GAAG,SAAbA,UAAa,CAACC,EAAD,EAAKC,UAAL,EAAoB;AACrC;AACA9E,EAAAA,eAAe;;AAEf,MAAI,CAACd,SAAS,GAAG6F,QAAjB,EAA2B;AACzB7F,IAAAA,SAAS,GAAG6F,QAAZ,GAAuBzE,SAAS,CAACwE,UAAD,CAAhC;AACD;;AAED,MAAI,CAACD,EAAL,EAAS;AACP9F,IAAAA,GAAG,CAAC,iBAAD,CAAH;AACA;AACD;;AAED,MAAI8F,EAAE,YAAYG,OAAlB,EAA2B;AACzB9F,IAAAA,SAAS,GAAG6F,QAAZ,CAAqBxE,OAArB,CAA6BsE,EAA7B;AACD,GAFD,MAEO,IAAIA,EAAE,CAAClB,MAAP,EAAe;AAAA;;AACpB,QAAMsB,GAAG,GAAGC,KAAK,CAACC,IAAN,CAAWN,EAAX,CAAZ;;AACA,2BAAA3F,SAAS,GAAG6F,QAAZ,EAAqBxE,OAArB,+CAAgC0E,GAAhC;AACD;AACF,CAnBD;AAqBA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AACAG,oBAAYC,MAAZ,GAAqB;AACnB,gBAAc;AACZC,IAAAA,OAAO,EAAE,OADG;AAEZ,kBAAc,QAFF;AAGZC,IAAAA,MAAM,EAAE;AAHI;AADK,CAArB;eAQeX,U","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 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\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"],"file":"render-math.js"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@pie-lib/math-rendering",
|
|
3
|
+
"version": "2.4.0",
|
|
4
|
+
"description": "math rendering utilities",
|
|
5
|
+
"publishConfig": {
|
|
6
|
+
"access": "public"
|
|
7
|
+
},
|
|
8
|
+
"main": "lib/index.js",
|
|
9
|
+
"module": "src/index.js",
|
|
10
|
+
"author": "pie-framework developers",
|
|
11
|
+
"license": "ISC",
|
|
12
|
+
"dependencies": {
|
|
13
|
+
"debug": "^4.1.1",
|
|
14
|
+
"lodash": "^4.17.11",
|
|
15
|
+
"mathjax-full": "^3.2.0"
|
|
16
|
+
},
|
|
17
|
+
"gitHead": "15c7a1364de782a095f8387f6be54af23e45fa10",
|
|
18
|
+
"scripts": {}
|
|
19
|
+
}
|