mathpix-markdown-it 2.0.24 → 2.0.25
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/README.md +1 -0
- package/es5/bundle.js +1 -1
- package/es5/context-menu.js +1 -1
- package/es5/index.js +7 -7
- package/lib/contex-menu/menu/consts.d.ts +1 -0
- package/lib/contex-menu/menu/consts.js +2 -0
- package/lib/contex-menu/menu/consts.js.map +1 -1
- package/lib/contex-menu/menu/menu-item.js +4 -0
- package/lib/contex-menu/menu/menu-item.js.map +1 -1
- package/lib/helpers/parse-mmd-element.js +2 -2
- package/lib/helpers/parse-mmd-element.js.map +1 -1
- package/lib/markdown/common/convert-math-to-html.js +2 -0
- package/lib/markdown/common/convert-math-to-html.js.map +1 -1
- package/lib/markdown/common/render-table-cell-content.js +2 -2
- package/lib/markdown/md-renderer-rules/render-tabular.js.map +1 -1
- package/lib/mathjax/index.d.ts +6 -0
- package/lib/mathjax/index.js +35 -16
- package/lib/mathjax/index.js.map +1 -1
- package/lib/mathjax/serialized-ascii/common.d.ts +6 -4
- package/lib/mathjax/serialized-ascii/common.js +26 -14
- package/lib/mathjax/serialized-ascii/common.js.map +1 -1
- package/lib/mathjax/serialized-ascii/handlers.d.ts +9 -3
- package/lib/mathjax/serialized-ascii/handlers.js +673 -448
- package/lib/mathjax/serialized-ascii/handlers.js.map +1 -1
- package/lib/mathjax/serialized-ascii/helperA.d.ts +413 -0
- package/lib/mathjax/serialized-ascii/helperA.js +25 -2
- package/lib/mathjax/serialized-ascii/helperA.js.map +1 -1
- package/lib/mathjax/serialized-ascii/helperLinear.d.ts +32 -0
- package/lib/mathjax/serialized-ascii/helperLinear.js +216 -0
- package/lib/mathjax/serialized-ascii/helperLinear.js.map +1 -0
- package/lib/mathjax/serialized-ascii/index.js +130 -96
- package/lib/mathjax/serialized-ascii/index.js.map +1 -1
- package/lib/mathjax/serialized-ascii/node-utils.d.ts +2 -0
- package/lib/mathjax/serialized-ascii/node-utils.js +12 -0
- package/lib/mathjax/serialized-ascii/node-utils.js.map +1 -0
- package/lib/mathpix-markdown-model/index.d.ts +1 -0
- package/lib/mathpix-markdown-model/index.js.map +1 -1
- package/package.json +1 -1
|
@@ -6,16 +6,12 @@ var MmlNode_1 = require("mathjax-full/js/core/MmlTree/MmlNode");
|
|
|
6
6
|
var helperA_1 = require("./helperA");
|
|
7
7
|
var consts_1 = require("../../helpers/consts");
|
|
8
8
|
var common_1 = require("./common");
|
|
9
|
+
var helperLinear_1 = require("./helperLinear");
|
|
10
|
+
var node_utils_1 = require("./node-utils");
|
|
9
11
|
var regW = /^\w/;
|
|
10
|
-
var isFirstChild = function (node) {
|
|
11
|
-
return node.parent && node.parent.childNodes[0] && node.parent.childNodes[0] === node;
|
|
12
|
-
};
|
|
13
|
-
var isLastChild = function (node) {
|
|
14
|
-
return node.parent && node.parent.childNodes && node.parent.childNodes[node.parent.childNodes.length - 1] === node;
|
|
15
|
-
};
|
|
16
12
|
var needFirstSpaceBeforeTeXAtom = function (node) {
|
|
17
13
|
var _a;
|
|
18
|
-
if (isFirstChild(node)) {
|
|
14
|
+
if ((0, node_utils_1.isFirstChild)(node)) {
|
|
19
15
|
return false;
|
|
20
16
|
}
|
|
21
17
|
if (node.kind === 'TeXAtom' && ((_a = node.properties) === null || _a === void 0 ? void 0 : _a.texClass) === MmlNode_1.TEXCLASS.OP) {
|
|
@@ -31,7 +27,7 @@ var needFirstSpaceBeforeTeXAtom = function (node) {
|
|
|
31
27
|
exports.needFirstSpaceBeforeTeXAtom = needFirstSpaceBeforeTeXAtom;
|
|
32
28
|
var needLastSpaceAfterTeXAtom = function (node) {
|
|
33
29
|
var _a;
|
|
34
|
-
if (isLastChild(node)) {
|
|
30
|
+
if ((0, node_utils_1.isLastChild)(node)) {
|
|
35
31
|
return false;
|
|
36
32
|
}
|
|
37
33
|
if (node.kind === 'TeXAtom' && ((_a = node.properties) === null || _a === void 0 ? void 0 : _a.texClass) === MmlNode_1.TEXCLASS.OP) {
|
|
@@ -45,9 +41,10 @@ var needLastSpaceAfterTeXAtom = function (node) {
|
|
|
45
41
|
return false;
|
|
46
42
|
};
|
|
47
43
|
exports.needLastSpaceAfterTeXAtom = needLastSpaceAfterTeXAtom;
|
|
48
|
-
var needFirstSpace = function (node) {
|
|
44
|
+
var needFirstSpace = function (node, isLinear) {
|
|
45
|
+
if (isLinear === void 0) { isLinear = false; }
|
|
49
46
|
try {
|
|
50
|
-
if (isFirstChild(node)) {
|
|
47
|
+
if ((0, node_utils_1.isFirstChild)(node)) {
|
|
51
48
|
return false;
|
|
52
49
|
}
|
|
53
50
|
else {
|
|
@@ -57,7 +54,7 @@ var needFirstSpace = function (node) {
|
|
|
57
54
|
if (hasLastSpace) {
|
|
58
55
|
return false;
|
|
59
56
|
}
|
|
60
|
-
if (prev.kind === 'mi' || prev.kind === 'mo') {
|
|
57
|
+
if (prev.kind === 'mi' || (prev.kind === 'mo' && !isLinear)) {
|
|
61
58
|
var text = prev.childNodes[0] ? prev.childNodes[0].text : '';
|
|
62
59
|
return regW.test(text[0]);
|
|
63
60
|
}
|
|
@@ -71,21 +68,22 @@ var needFirstSpace = function (node) {
|
|
|
71
68
|
}
|
|
72
69
|
};
|
|
73
70
|
exports.needFirstSpace = needFirstSpace;
|
|
74
|
-
var needLastSpace = function (node, isFunction) {
|
|
71
|
+
var needLastSpace = function (node, isFunction, isLinear) {
|
|
75
72
|
var _a;
|
|
76
73
|
if (isFunction === void 0) { isFunction = false; }
|
|
74
|
+
if (isLinear === void 0) { isLinear = false; }
|
|
77
75
|
var haveSpace = false;
|
|
78
76
|
try {
|
|
79
77
|
if (node.parent.kind === "msubsup") {
|
|
80
78
|
return false;
|
|
81
79
|
}
|
|
82
|
-
if (isLastChild(node)) {
|
|
80
|
+
if ((0, node_utils_1.isLastChild)(node)) {
|
|
83
81
|
return false;
|
|
84
82
|
}
|
|
85
83
|
else {
|
|
86
84
|
var index = node.parent.childNodes.findIndex(function (item) { return item === node; });
|
|
87
85
|
var next = node.parent.childNodes[index + 1];
|
|
88
|
-
if (next.childNodes[0].kind === 'text' && next.childNodes[0].text === '\u2061' && !isLastChild(next)) {
|
|
86
|
+
if (next.childNodes[0].kind === 'text' && next.childNodes[0].text === '\u2061' && !(0, node_utils_1.isLastChild)(next)) {
|
|
89
87
|
next = node.parent.childNodes[index + 2];
|
|
90
88
|
haveSpace = true;
|
|
91
89
|
}
|
|
@@ -101,8 +99,8 @@ var needLastSpace = function (node, isFunction) {
|
|
|
101
99
|
if (next.childNodes[0] && next.childNodes[0].kind === 'text' && next.childNodes[0].text === '\u2061') {
|
|
102
100
|
return true;
|
|
103
101
|
}
|
|
104
|
-
var
|
|
105
|
-
return regW.test(
|
|
102
|
+
var data = (0, exports.SymbolToAM)(next.kind, text);
|
|
103
|
+
return isLinear ? regW.test(data.linear) : regW.test(data.ascii);
|
|
106
104
|
}
|
|
107
105
|
else {
|
|
108
106
|
if (next.kind === 'mrow') {
|
|
@@ -151,41 +149,44 @@ var SymbolToAM = function (tag, output, atr, showStyle) {
|
|
|
151
149
|
finally { if (e_1) throw e_1.error; }
|
|
152
150
|
}
|
|
153
151
|
if (tags && tags.input) {
|
|
154
|
-
return
|
|
152
|
+
return {
|
|
153
|
+
ascii: tags.input + '(' + output + ')',
|
|
154
|
+
linear: tags.output + '(' + output + ')'
|
|
155
|
+
};
|
|
155
156
|
}
|
|
156
157
|
}
|
|
157
158
|
if (!tags) {
|
|
158
|
-
tags = helperA_1.
|
|
159
|
-
if (tag === 'mo' || tag === 'mi') {
|
|
160
|
-
return (item.tag === 'mo' || item.tag === 'mi') && item.output === output;
|
|
161
|
-
}
|
|
162
|
-
else {
|
|
163
|
-
return item.tag === tag && item.output === output;
|
|
164
|
-
}
|
|
165
|
-
});
|
|
159
|
+
tags = (0, helperA_1.findAmSymbolByTag)(tag, output);
|
|
166
160
|
}
|
|
167
161
|
//need split
|
|
168
162
|
if (!tags && atr && atrsNames.length > 0 && Object.getOwnPropertyNames(atr) && atr.stretchy === false) {
|
|
169
|
-
var
|
|
163
|
+
var sp = output.split('');
|
|
170
164
|
var res = '';
|
|
171
|
-
var
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
return (item.tag === 'mo' || item.tag === 'mi') && item.output === sp_1[i];
|
|
175
|
-
}
|
|
176
|
-
else {
|
|
177
|
-
return item.tag === tag && item.output === sp_1[i];
|
|
178
|
-
}
|
|
179
|
-
});
|
|
165
|
+
var res_linear = '';
|
|
166
|
+
for (var i = 0; i < sp.length; i++) {
|
|
167
|
+
var tags_1 = (0, helperA_1.findAmSymbolByTag)(tag, sp[i]);
|
|
180
168
|
res += i > 0 ? ' ' : '';
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
169
|
+
res_linear += i > 0 ? ' ' : '';
|
|
170
|
+
res += tags_1 && tags_1.input ? tags_1.input : sp[i];
|
|
171
|
+
res_linear += tags_1 && tags_1.output
|
|
172
|
+
? tags_1.output_linear
|
|
173
|
+
? tags_1.output_linear
|
|
174
|
+
: tags_1.output
|
|
175
|
+
: sp[i];
|
|
185
176
|
}
|
|
186
|
-
return
|
|
177
|
+
return {
|
|
178
|
+
ascii: res,
|
|
179
|
+
linear: res_linear ? res_linear.split(' ').join('') : ''
|
|
180
|
+
};
|
|
187
181
|
}
|
|
188
|
-
return
|
|
182
|
+
return {
|
|
183
|
+
ascii: tags ? tags.input : output,
|
|
184
|
+
linear: tags
|
|
185
|
+
? tags.output_linear
|
|
186
|
+
? tags.output_linear
|
|
187
|
+
: tags.output
|
|
188
|
+
: output
|
|
189
|
+
};
|
|
189
190
|
};
|
|
190
191
|
exports.SymbolToAM = SymbolToAM;
|
|
191
192
|
var FindSymbolReplace = function (str) {
|
|
@@ -197,26 +198,19 @@ var FindSymbolToAM = function (tag, output, atr) {
|
|
|
197
198
|
output = output.split(' ').join('');
|
|
198
199
|
var tags = null;
|
|
199
200
|
if (atr && atr.stretchy) {
|
|
200
|
-
tags = helperA_1.
|
|
201
|
-
if (tag === 'mo' || tag === 'mi') {
|
|
202
|
-
return (item.tag === 'mo' || item.tag === 'mi') && item.output === output && item.stretchy;
|
|
203
|
-
}
|
|
204
|
-
else {
|
|
205
|
-
return item.tag === tag && item.output === output && item.stretchy;
|
|
206
|
-
}
|
|
207
|
-
});
|
|
201
|
+
tags = (0, helperA_1.findAmSymbolByTagStretchy)(tag, output);
|
|
208
202
|
}
|
|
209
203
|
if (!tags) {
|
|
210
|
-
tags = helperA_1.
|
|
211
|
-
if (tag === 'mo' || tag === 'mi') {
|
|
212
|
-
return (item.tag === 'mo' || item.tag === 'mi') && item.output === output;
|
|
213
|
-
}
|
|
214
|
-
else {
|
|
215
|
-
return item.tag === tag && item.output === output;
|
|
216
|
-
}
|
|
217
|
-
});
|
|
204
|
+
tags = (0, helperA_1.findAmSymbolByTag)(tag, output);
|
|
218
205
|
}
|
|
219
|
-
return
|
|
206
|
+
return {
|
|
207
|
+
ascii: tags ? tags.input : '',
|
|
208
|
+
linear: tags
|
|
209
|
+
? tags.output_linear
|
|
210
|
+
? tags.output_linear
|
|
211
|
+
: tags.output
|
|
212
|
+
: output
|
|
213
|
+
};
|
|
220
214
|
};
|
|
221
215
|
exports.FindSymbolToAM = FindSymbolToAM;
|
|
222
216
|
var getChildrenText = function (node) {
|
|
@@ -240,12 +234,7 @@ var getAttributes = function (node) {
|
|
|
240
234
|
exports.getAttributes = getAttributes;
|
|
241
235
|
var menclose = function (handlerApi) {
|
|
242
236
|
return function (node, serialize) {
|
|
243
|
-
var res =
|
|
244
|
-
ascii: '',
|
|
245
|
-
ascii_tsv: '',
|
|
246
|
-
ascii_csv: '',
|
|
247
|
-
ascii_md: '',
|
|
248
|
-
};
|
|
237
|
+
var res = (0, common_1.initAsciiData)();
|
|
249
238
|
try {
|
|
250
239
|
var atr = (0, exports.getAttributes)(node);
|
|
251
240
|
var isLeft = false;
|
|
@@ -254,13 +243,19 @@ var menclose = function (handlerApi) {
|
|
|
254
243
|
isLeft = atr.notation.toString().indexOf('left') > -1;
|
|
255
244
|
isRight = atr.notation.toString().indexOf('right') > -1;
|
|
256
245
|
}
|
|
257
|
-
res = (0, common_1.AddToAsciiData)(res,
|
|
246
|
+
res = (0, common_1.AddToAsciiData)(res, {
|
|
247
|
+
ascii: isLeft ? '[' : '',
|
|
248
|
+
linear: ''
|
|
249
|
+
});
|
|
258
250
|
var data = handlerApi.handleAll(node, serialize);
|
|
259
|
-
res = (0, common_1.AddToAsciiData)(res,
|
|
251
|
+
res = (0, common_1.AddToAsciiData)(res, data);
|
|
260
252
|
if (atr && atr.lcm) {
|
|
261
|
-
res = (0, common_1.AddToAsciiData)(res,
|
|
253
|
+
res = (0, common_1.AddToAsciiData)(res, { ascii: '', linear: '' });
|
|
262
254
|
}
|
|
263
|
-
res = (0, common_1.AddToAsciiData)(res,
|
|
255
|
+
res = (0, common_1.AddToAsciiData)(res, {
|
|
256
|
+
ascii: isRight ? ']' : '',
|
|
257
|
+
linear: ''
|
|
258
|
+
});
|
|
264
259
|
return res;
|
|
265
260
|
}
|
|
266
261
|
catch (e) {
|
|
@@ -276,14 +271,21 @@ var getNodeFromRow = function (node) {
|
|
|
276
271
|
return node;
|
|
277
272
|
};
|
|
278
273
|
var getDataForVerticalMath = function (serialize, node, rowNumber) {
|
|
274
|
+
var _a;
|
|
279
275
|
var mtdNode = getNodeFromRow(node);
|
|
280
276
|
var res = {
|
|
281
277
|
collChildrenCanBeVerticalMath: true,
|
|
282
278
|
startedFromMathOperation: false,
|
|
283
279
|
mmlCollVerticalMath: '',
|
|
280
|
+
mmlCollVerticalMath_linear: '',
|
|
284
281
|
mathOperation: ''
|
|
285
282
|
};
|
|
283
|
+
var parenthesisLinearOpen = false;
|
|
286
284
|
for (var k = 0; k < mtdNode.childNodes.length; k++) {
|
|
285
|
+
if (parenthesisLinearOpen) {
|
|
286
|
+
res.mmlCollVerticalMath_linear += ')';
|
|
287
|
+
parenthesisLinearOpen = false;
|
|
288
|
+
}
|
|
287
289
|
var child = mtdNode.childNodes[k];
|
|
288
290
|
/** The element is wrapped in curly braces:
|
|
289
291
|
* e.g. {\times 1}*/
|
|
@@ -299,10 +301,17 @@ var getDataForVerticalMath = function (serialize, node, rowNumber) {
|
|
|
299
301
|
res.mathOperation = data_1.mathOperation;
|
|
300
302
|
}
|
|
301
303
|
res.mmlCollVerticalMath += data_1.mmlCollVerticalMath;
|
|
304
|
+
res.mmlCollVerticalMath_linear += data_1.mmlCollVerticalMath_linear;
|
|
302
305
|
continue;
|
|
303
306
|
}
|
|
304
307
|
var data = serialize.visitNode(child, '');
|
|
305
308
|
var text = getChildrenText(child);
|
|
309
|
+
if ((child === null || child === void 0 ? void 0 : child.kind) === "mfrac"
|
|
310
|
+
&& (((_a = res.mmlCollVerticalMath_linear) === null || _a === void 0 ? void 0 : _a.trim()) && (0, helperLinear_1.needsParensForFollowingDivision)(res.mmlCollVerticalMath_linear)
|
|
311
|
+
|| (0, helperLinear_1.needBrackets)(serialize, child))) {
|
|
312
|
+
res.mmlCollVerticalMath_linear += '(';
|
|
313
|
+
parenthesisLinearOpen = true;
|
|
314
|
+
}
|
|
306
315
|
if (child.kind === 'mo') {
|
|
307
316
|
var symbolType = (0, exports.getSymbolType)('mo', text);
|
|
308
317
|
if (symbolType === helperA_1.eSymbolType.logical
|
|
@@ -324,8 +333,12 @@ var getDataForVerticalMath = function (serialize, node, rowNumber) {
|
|
|
324
333
|
}
|
|
325
334
|
}
|
|
326
335
|
res.mmlCollVerticalMath += data.ascii === '","' ? ',' : data.ascii;
|
|
336
|
+
res.mmlCollVerticalMath_linear += data.linear === '","' ? ',' : data.linear;
|
|
327
337
|
}
|
|
328
338
|
}
|
|
339
|
+
if (parenthesisLinearOpen) {
|
|
340
|
+
res.mmlCollVerticalMath_linear += ')';
|
|
341
|
+
}
|
|
329
342
|
return res;
|
|
330
343
|
};
|
|
331
344
|
var mtable = function () {
|
|
@@ -351,18 +364,22 @@ var mtable = function () {
|
|
|
351
364
|
node.attributes.setInherited('toCsv', toCsv);
|
|
352
365
|
node.attributes.setInherited('toMd', toMd);
|
|
353
366
|
var columnAlign = node.attributes.get('columnalign');
|
|
367
|
+
var columnAlignArr = columnAlign ? columnAlign.split(' ') : [];
|
|
354
368
|
var arrRowLines = node.attributes.isSet('rowlines') ? node.attributes.get('rowlines').split(' ') : [];
|
|
355
369
|
var envName = node.attributes.get('name');
|
|
356
370
|
/** Check if a table is enclosed in brackets */
|
|
357
371
|
var isHasBranchOpen = node.parent && node.parent.kind === 'mrow' && ((_h = node.parent.properties) === null || _h === void 0 ? void 0 : _h.hasOwnProperty('open'));
|
|
358
372
|
var isHasBranchClose = node.parent && node.parent.kind === 'mrow' && ((_j = node.parent.properties) === null || _j === void 0 ? void 0 : _j.hasOwnProperty('close'));
|
|
373
|
+
var branchOpen = !!isHasBranchOpen && node.parent.properties['open'];
|
|
374
|
+
var branchClose = !!isHasBranchClose && node.parent.properties['close'];
|
|
359
375
|
var thereAreBracketsIn_parent = (isHasBranchOpen && node.parent.properties['open'])
|
|
360
376
|
|| (isHasBranchClose && node.parent.properties['close']);
|
|
361
377
|
var thereAreBracketsIn_Parent = parentIsMenclose && ((_k = node.Parent.Parent) === null || _k === void 0 ? void 0 : _k.isKind('mrow'))
|
|
362
378
|
&& ((((_l = node.Parent.Parent.properties) === null || _l === void 0 ? void 0 : _l.hasOwnProperty('open')) && node.Parent.Parent.properties['open'])
|
|
363
379
|
|| (((_m = node.Parent.Parent.properties) === null || _m === void 0 ? void 0 : _m.hasOwnProperty('close')) && node.Parent.Parent.properties['close']));
|
|
364
380
|
/** It is a matrix or system of equations with brackets */
|
|
365
|
-
var isMatrixOrSystemOfEquations = thereAreBracketsIn_parent || thereAreBracketsIn_Parent;
|
|
381
|
+
var isMatrixOrSystemOfEquations = !!thereAreBracketsIn_parent || !!thereAreBracketsIn_Parent;
|
|
382
|
+
var isMatrix = (!!thereAreBracketsIn_parent || !!thereAreBracketsIn_Parent) && !!branchOpen && !!branchClose;
|
|
366
383
|
var itShouldBeFlatten = consts_1.envArraysShouldBeFlattenInTSV.includes(envName)
|
|
367
384
|
&& !isHasBranchOpen && !isHasBranchClose && !parentIsMenclose;
|
|
368
385
|
/** Vertical math:
|
|
@@ -377,28 +394,40 @@ var mtable = function () {
|
|
|
377
394
|
mtrNode.attributes.setInherited('toMd', toMd);
|
|
378
395
|
mtrNode.attributes.setInherited('itShouldBeFlatten', itShouldBeFlatten);
|
|
379
396
|
var mmlRow = '';
|
|
397
|
+
var mmlRow_linear = '';
|
|
380
398
|
var mmlRow_tsv = '';
|
|
381
399
|
var mmlRow_csv = '';
|
|
382
400
|
var mmlRow_md = '';
|
|
383
401
|
var mmlRowVerticalMath = '';
|
|
402
|
+
var mmlRowVerticalMath_linear = '';
|
|
384
403
|
var mathOperation = '';
|
|
385
404
|
var countColl = (_o = mtrNode.childNodes) === null || _o === void 0 ? void 0 : _o.length;
|
|
386
405
|
/** It's EqnArray or AmsEqnArray or AlignAt.
|
|
387
406
|
* eqnarray*, align, align*, split, gather, gather*, aligned, gathered, alignat, alignat*, alignedat */
|
|
388
407
|
var isEqnArrayRow = mtrNode.attributes.get('displaystyle');
|
|
389
408
|
for (var j = 0; j < countColl; j++) {
|
|
390
|
-
if (j > 0
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
409
|
+
if (j > 0) {
|
|
410
|
+
if (!isEqnArrayRow) {
|
|
411
|
+
mmlRow += ',';
|
|
412
|
+
mmlRow_linear += isMatrix ? ',' : ' ';
|
|
413
|
+
mmlRow_tsv += toTsv ? ((_p = serialize.options.tsv_separators) === null || _p === void 0 ? void 0 : _p.column) || '\t' : itShouldBeFlatten ? ', ' : ',';
|
|
414
|
+
mmlRow_csv += toCsv ? ((_q = serialize.options.csv_separators) === null || _q === void 0 ? void 0 : _q.column) || ',' : itShouldBeFlatten ? ', ' : ',';
|
|
415
|
+
mmlRow_md += toMd ? ((_r = serialize.options.md_separators) === null || _r === void 0 ? void 0 : _r.column) || ' ' : itShouldBeFlatten ? ', ' : ',';
|
|
416
|
+
}
|
|
417
|
+
else {
|
|
418
|
+
if ((columnAlignArr === null || columnAlignArr === void 0 ? void 0 : columnAlignArr.length) && columnAlignArr[j - 1] === 'left' && columnAlignArr[j] === 'right') {
|
|
419
|
+
mmlRow_linear += isMatrix ? ',' : ' ';
|
|
420
|
+
}
|
|
421
|
+
}
|
|
395
422
|
}
|
|
396
423
|
var mtdNode = mtrNode.childNodes[j];
|
|
397
|
-
var _0 = serialize.visitNode(mtdNode, ''), _1 = _0.ascii, ascii = _1 === void 0 ? '' : _1, _2 = _0.
|
|
424
|
+
var _0 = serialize.visitNode(mtdNode, ''), _1 = _0.ascii, ascii = _1 === void 0 ? '' : _1, _2 = _0.linear, linear = _2 === void 0 ? '' : _2, _3 = _0.ascii_tsv, ascii_tsv = _3 === void 0 ? '' : _3, _4 = _0.ascii_csv, ascii_csv = _4 === void 0 ? '' : _4, _5 = _0.ascii_md, ascii_md = _5 === void 0 ? '' : _5;
|
|
398
425
|
var mmlCollVerticalMath = '';
|
|
426
|
+
var mmlCollVerticalMath_linear = '';
|
|
399
427
|
if (isVerticalMath) {
|
|
400
428
|
var dataColl = getDataForVerticalMath(serialize, mtdNode, i);
|
|
401
429
|
mmlCollVerticalMath = dataColl.mmlCollVerticalMath;
|
|
430
|
+
mmlCollVerticalMath_linear = dataColl.mmlCollVerticalMath_linear;
|
|
402
431
|
if (dataColl.startedFromMathOperation) {
|
|
403
432
|
startedFromMathOperation = true;
|
|
404
433
|
mathOperation = dataColl.mathOperation;
|
|
@@ -408,25 +437,30 @@ var mtable = function () {
|
|
|
408
437
|
}
|
|
409
438
|
}
|
|
410
439
|
mmlRow += ascii;
|
|
440
|
+
mmlRow_linear += linear;
|
|
411
441
|
mmlRow_tsv += !toTsv && itShouldBeFlatten ? ascii_tsv.trimEnd() : ascii_tsv;
|
|
412
442
|
mmlRow_csv += !toCsv && itShouldBeFlatten ? ascii_csv.trimEnd() : ascii_csv;
|
|
413
443
|
mmlRow_md += !toMd && itShouldBeFlatten ? ascii_md.trimEnd() : ascii_md;
|
|
414
444
|
mmlRowVerticalMath += mmlCollVerticalMath;
|
|
445
|
+
mmlRowVerticalMath_linear += mmlCollVerticalMath_linear;
|
|
415
446
|
}
|
|
416
447
|
/** For vertical math, if the horizontal line is in front of the answer, then replace it with an equals sign */
|
|
417
448
|
if (isVerticalMath &&
|
|
418
449
|
(arrRowLines === null || arrRowLines === void 0 ? void 0 : arrRowLines.length) && (arrRowLines === null || arrRowLines === void 0 ? void 0 : arrRowLines.length) > i && arrRowLines[i] !== 'none') {
|
|
419
450
|
mmlRowVerticalMath += '=';
|
|
451
|
+
mmlRowVerticalMath_linear += '=';
|
|
420
452
|
}
|
|
421
453
|
/** It's EqnArray or AmsEqnArray or AlignAt.
|
|
422
454
|
* eqnarray*, align, align*, split, gather, gather*, aligned, gathered, alignat, alignat*, alignedat */
|
|
423
455
|
var isEqnArray = (_s = mtrNode.attributes) === null || _s === void 0 ? void 0 : _s.get('displaystyle');
|
|
424
456
|
arrRows.push({
|
|
425
457
|
mmlRow: mmlRow,
|
|
458
|
+
mmlRow_linear: mmlRow_linear,
|
|
426
459
|
mmlRow_tsv: mmlRow_tsv,
|
|
427
460
|
mmlRow_csv: mmlRow_csv,
|
|
428
461
|
mmlRow_md: mmlRow_md,
|
|
429
462
|
mmlRowVerticalMath: mmlRowVerticalMath,
|
|
463
|
+
mmlRowVerticalMath_linear: mmlRowVerticalMath_linear,
|
|
430
464
|
mathOperation: mathOperation,
|
|
431
465
|
encloseToSquareBrackets: countRow > 1 || isSubExpression || (countColl > 1 && !isEqnArray),
|
|
432
466
|
toTsv: toTsv,
|
|
@@ -450,10 +484,12 @@ var mtable = function () {
|
|
|
450
484
|
}
|
|
451
485
|
if (mathOperation && i > 0) {
|
|
452
486
|
arrRows[i].mmlRowVerticalMath = mathOperation + arrRows[i].mmlRowVerticalMath;
|
|
487
|
+
arrRows[i].mmlRowVerticalMath_linear = mathOperation + arrRows[i].mmlRowVerticalMath_linear;
|
|
453
488
|
}
|
|
454
489
|
}
|
|
455
490
|
}
|
|
456
491
|
var mmlTableContent = '';
|
|
492
|
+
var mmlTableContent_linear = '';
|
|
457
493
|
var mmlTableContent_tsv = '';
|
|
458
494
|
var mmlTableContent_csv = '';
|
|
459
495
|
var mmlTableContent_md = '';
|
|
@@ -469,14 +505,25 @@ var mtable = function () {
|
|
|
469
505
|
mmlTableContent_md += toMd
|
|
470
506
|
? ((_v = serialize.options.md_separators) === null || _v === void 0 ? void 0 : _v.row) || ' <br> '
|
|
471
507
|
: itShouldBeFlatten ? ', ' : ',';
|
|
508
|
+
if (isMatrix) {
|
|
509
|
+
mmlTableContent_linear += ',';
|
|
510
|
+
}
|
|
472
511
|
}
|
|
473
512
|
var mmlRow = isVerticalMath ? arrRows[i].mmlRowVerticalMath : arrRows[i].mmlRow;
|
|
513
|
+
var mmlRow_linear = isVerticalMath ? arrRows[i].mmlRowVerticalMath_linear : arrRows[i].mmlRow_linear;
|
|
474
514
|
var mmlRow_tsv = isVerticalMath ? arrRows[i].mmlRowVerticalMath : arrRows[i].mmlRow_tsv;
|
|
475
515
|
var mmlRow_csv = isVerticalMath ? arrRows[i].mmlRowVerticalMath : arrRows[i].mmlRow_csv;
|
|
476
516
|
var mmlRow_md = isVerticalMath ? arrRows[i].mmlRowVerticalMath : arrRows[i].mmlRow_md;
|
|
477
517
|
mmlTableContent += arrRows[i].encloseToSquareBrackets && !isVerticalMath
|
|
478
518
|
? '[' + mmlRow + ']'
|
|
479
519
|
: mmlRow;
|
|
520
|
+
if (arrRows[i].encloseToSquareBrackets && !isVerticalMath && isMatrix) {
|
|
521
|
+
mmlTableContent_linear += '[' + mmlRow_linear + ']';
|
|
522
|
+
}
|
|
523
|
+
else {
|
|
524
|
+
mmlTableContent_linear += mmlTableContent_linear && !isVerticalMath ? '\n' : '';
|
|
525
|
+
mmlTableContent_linear += mmlRow_linear;
|
|
526
|
+
}
|
|
480
527
|
mmlTableContent_tsv += arrRows[i].encloseToSquareBrackets
|
|
481
528
|
&& !arrRows[i].itShouldBeFlatten && !arrRows[i].toTsv && !isVerticalMath
|
|
482
529
|
? '[' + mmlRow_tsv + ']'
|
|
@@ -547,18 +594,20 @@ var mtable = function () {
|
|
|
547
594
|
}
|
|
548
595
|
return {
|
|
549
596
|
ascii: mml,
|
|
597
|
+
linear: mmlTableContent_linear,
|
|
550
598
|
ascii_tsv: mml_tsv,
|
|
551
599
|
ascii_csv: mml_csv,
|
|
552
|
-
ascii_md: mml_md
|
|
600
|
+
ascii_md: mml_md
|
|
553
601
|
};
|
|
554
602
|
}
|
|
555
603
|
catch (e) {
|
|
556
604
|
console.error('mml => mtable =>', e);
|
|
557
605
|
return {
|
|
558
606
|
ascii: mml,
|
|
607
|
+
linear: mml,
|
|
559
608
|
ascii_tsv: mml_tsv,
|
|
560
609
|
ascii_csv: mml_csv,
|
|
561
|
-
ascii_md: mml_md
|
|
610
|
+
ascii_md: mml_md
|
|
562
611
|
};
|
|
563
612
|
}
|
|
564
613
|
};
|
|
@@ -573,6 +622,7 @@ var mrow = function () {
|
|
|
573
622
|
var needBranchClose = node.properties
|
|
574
623
|
&& node.properties.hasOwnProperty('close') && node.properties.close === '';
|
|
575
624
|
var mmlContent = '';
|
|
625
|
+
var mmlContent_linear = '';
|
|
576
626
|
var mmlContent_tsv = '';
|
|
577
627
|
var mmlContent_csv = '';
|
|
578
628
|
var mmlContent_md = '';
|
|
@@ -585,6 +635,7 @@ var mrow = function () {
|
|
|
585
635
|
var text = (0, common_1.getFunctionNameFromAscii)(data.ascii, node.childNodes[i]);
|
|
586
636
|
if (!text || helperA_1.regExpIsFunction.test(text)) {
|
|
587
637
|
mmlContent += ')';
|
|
638
|
+
mmlContent_linear += ')';
|
|
588
639
|
mmlContent_tsv += ')';
|
|
589
640
|
mmlContent_csv += ')';
|
|
590
641
|
mmlContent_md += ')';
|
|
@@ -594,6 +645,7 @@ var mrow = function () {
|
|
|
594
645
|
if (node.childNodes[i].kind === "mfrac" && (beforeAscii === null || beforeAscii === void 0 ? void 0 : beforeAscii.trim())) {
|
|
595
646
|
if (helperA_1.regExpIsFunction.test(beforeAscii.trim()) || ((childBefore === null || childBefore === void 0 ? void 0 : childBefore.kind) === 'mo' && (childBefore === null || childBefore === void 0 ? void 0 : childBefore.texClass) === -1)) {
|
|
596
647
|
mmlContent += '(';
|
|
648
|
+
mmlContent_linear += '(';
|
|
597
649
|
mmlContent_tsv += '(';
|
|
598
650
|
mmlContent_csv += '(';
|
|
599
651
|
mmlContent_md += '(';
|
|
@@ -601,6 +653,7 @@ var mrow = function () {
|
|
|
601
653
|
}
|
|
602
654
|
}
|
|
603
655
|
mmlContent += data.ascii;
|
|
656
|
+
mmlContent_linear += data.linear;
|
|
604
657
|
mmlContent_tsv += data.ascii_tsv;
|
|
605
658
|
mmlContent_csv += data.ascii_csv;
|
|
606
659
|
mmlContent_md += data.ascii_md;
|
|
@@ -609,6 +662,7 @@ var mrow = function () {
|
|
|
609
662
|
}
|
|
610
663
|
if (parenthesisOpen) {
|
|
611
664
|
mmlContent += ')';
|
|
665
|
+
mmlContent_linear += ')';
|
|
612
666
|
mmlContent_tsv += ')';
|
|
613
667
|
mmlContent_csv += ')';
|
|
614
668
|
mmlContent_md += ')';
|
|
@@ -618,6 +672,7 @@ var mrow = function () {
|
|
|
618
672
|
var close_1 = isTexClass7 && needBranchClose && !isVerticalMath ? ':}' : '';
|
|
619
673
|
return {
|
|
620
674
|
ascii: open_1 + mmlContent + close_1,
|
|
675
|
+
linear: mmlContent_linear,
|
|
621
676
|
ascii_tsv: open_1 + mmlContent_tsv + close_1,
|
|
622
677
|
ascii_csv: open_1 + mmlContent_csv + close_1,
|
|
623
678
|
ascii_md: open_1 + mmlContent_md + close_1,
|
|
@@ -625,24 +680,14 @@ var mrow = function () {
|
|
|
625
680
|
}
|
|
626
681
|
catch (e) {
|
|
627
682
|
console.error('mml => mrow =>', e);
|
|
628
|
-
return
|
|
629
|
-
ascii: '',
|
|
630
|
-
ascii_tsv: '',
|
|
631
|
-
ascii_csv: '',
|
|
632
|
-
ascii_md: '',
|
|
633
|
-
};
|
|
683
|
+
return (0, common_1.initAsciiData)();
|
|
634
684
|
}
|
|
635
685
|
};
|
|
636
686
|
};
|
|
637
687
|
var mtr = function () {
|
|
638
688
|
return function (node, serialize) {
|
|
639
689
|
var _a, _b, _c;
|
|
640
|
-
var res =
|
|
641
|
-
ascii: '',
|
|
642
|
-
ascii_tsv: '',
|
|
643
|
-
ascii_csv: '',
|
|
644
|
-
ascii_md: '',
|
|
645
|
-
};
|
|
690
|
+
var res = (0, common_1.initAsciiData)();
|
|
646
691
|
try {
|
|
647
692
|
/** It's EqnArray or AmsEqnArray or AlignAt.
|
|
648
693
|
* eqnarray*, align, align*, split, gather, gather*, aligned, gathered, alignat, alignat*, alignedat */
|
|
@@ -653,20 +698,22 @@ var mtr = function () {
|
|
|
653
698
|
var itShouldBeFlatten = node.attributes.get('itShouldBeFlatten');
|
|
654
699
|
for (var i = 0; i < node.childNodes.length; i++) {
|
|
655
700
|
if (i > 0 && !isEqnArray) {
|
|
656
|
-
res = (0, common_1.AddToAsciiData)(res,
|
|
657
|
-
',',
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
701
|
+
res = (0, common_1.AddToAsciiData)(res, {
|
|
702
|
+
ascii: ',',
|
|
703
|
+
linear: ' ',
|
|
704
|
+
ascii_tsv: toTsv ? ((_a = serialize.options.tsv_separators) === null || _a === void 0 ? void 0 : _a.column) || '\t' : itShouldBeFlatten ? ', ' : ',',
|
|
705
|
+
ascii_csv: toCsv ? ((_b = serialize.options.csv_separators) === null || _b === void 0 ? void 0 : _b.column) || ',' : itShouldBeFlatten ? ', ' : ',',
|
|
706
|
+
ascii_md: toMd ? ((_c = serialize.options.md_separators) === null || _c === void 0 ? void 0 : _c.column) || ' ' : itShouldBeFlatten ? ', ' : ','
|
|
707
|
+
});
|
|
662
708
|
}
|
|
663
|
-
var _d = serialize.visitNode(node.childNodes[i], ''), _e = _d.ascii, ascii = _e === void 0 ? '' : _e, _f = _d.
|
|
664
|
-
res = (0, common_1.AddToAsciiData)(res,
|
|
665
|
-
ascii,
|
|
666
|
-
|
|
667
|
-
!
|
|
668
|
-
!
|
|
669
|
-
|
|
709
|
+
var _d = serialize.visitNode(node.childNodes[i], ''), _e = _d.ascii, ascii = _e === void 0 ? '' : _e, _f = _d.linear, linear = _f === void 0 ? '' : _f, _g = _d.ascii_tsv, ascii_tsv = _g === void 0 ? '' : _g, _h = _d.ascii_csv, ascii_csv = _h === void 0 ? '' : _h, _j = _d.ascii_md, ascii_md = _j === void 0 ? '' : _j;
|
|
710
|
+
res = (0, common_1.AddToAsciiData)(res, {
|
|
711
|
+
ascii: ascii,
|
|
712
|
+
linear: linear,
|
|
713
|
+
ascii_tsv: !toTsv && itShouldBeFlatten ? ascii_tsv === null || ascii_tsv === void 0 ? void 0 : ascii_tsv.trimEnd() : ascii_tsv,
|
|
714
|
+
ascii_csv: !toCsv && itShouldBeFlatten ? ascii_csv === null || ascii_csv === void 0 ? void 0 : ascii_csv.trimEnd() : ascii_csv,
|
|
715
|
+
ascii_md: !toMd && itShouldBeFlatten ? ascii_md === null || ascii_md === void 0 ? void 0 : ascii_md.trimEnd() : ascii_md
|
|
716
|
+
});
|
|
670
717
|
}
|
|
671
718
|
return res;
|
|
672
719
|
}
|
|
@@ -678,12 +725,7 @@ var mtr = function () {
|
|
|
678
725
|
};
|
|
679
726
|
var mpadded = function (handlerApi) {
|
|
680
727
|
return function (node, serialize) {
|
|
681
|
-
var res =
|
|
682
|
-
ascii: '',
|
|
683
|
-
ascii_tsv: '',
|
|
684
|
-
ascii_csv: '',
|
|
685
|
-
ascii_md: ''
|
|
686
|
-
};
|
|
728
|
+
var res = (0, common_1.initAsciiData)();
|
|
687
729
|
try {
|
|
688
730
|
var mmlAdd = handlerApi.handleAll(node, serialize);
|
|
689
731
|
if (node.Parent && node.Parent.kind === "menclose") {
|
|
@@ -697,19 +739,21 @@ var mpadded = function (handlerApi) {
|
|
|
697
739
|
/** For tsv/csv:
|
|
698
740
|
* Omit the " in nested arrays
|
|
699
741
|
* */
|
|
700
|
-
res = (0, common_1.AddToAsciiData)(res,
|
|
701
|
-
'"',
|
|
702
|
-
|
|
703
|
-
'',
|
|
704
|
-
''
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
res = (0, common_1.AddToAsciiData)(res,
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
'',
|
|
711
|
-
''
|
|
712
|
-
|
|
742
|
+
res = (0, common_1.AddToAsciiData)(res, {
|
|
743
|
+
ascii: '"',
|
|
744
|
+
linear: '',
|
|
745
|
+
ascii_tsv: serialize.options.tableToTsv ? '' : '"',
|
|
746
|
+
ascii_csv: '',
|
|
747
|
+
ascii_md: ''
|
|
748
|
+
});
|
|
749
|
+
res = (0, common_1.AddToAsciiData)(res, mmlAdd);
|
|
750
|
+
res = (0, common_1.AddToAsciiData)(res, {
|
|
751
|
+
ascii: '"',
|
|
752
|
+
linear: '',
|
|
753
|
+
ascii_tsv: serialize.options.tableToTsv ? '' : '"',
|
|
754
|
+
ascii_csv: '',
|
|
755
|
+
ascii_md: ''
|
|
756
|
+
});
|
|
713
757
|
return res;
|
|
714
758
|
}
|
|
715
759
|
catch (e) {
|
|
@@ -720,12 +764,8 @@ var mpadded = function (handlerApi) {
|
|
|
720
764
|
};
|
|
721
765
|
var mover = function (handlerApi) {
|
|
722
766
|
return function (node, serialize) {
|
|
723
|
-
var
|
|
724
|
-
|
|
725
|
-
ascii_tsv: '',
|
|
726
|
-
ascii_csv: '',
|
|
727
|
-
ascii_md: ''
|
|
728
|
-
};
|
|
767
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
|
|
768
|
+
var res = (0, common_1.initAsciiData)();
|
|
729
769
|
try {
|
|
730
770
|
var firstChild = node.childNodes[0] ? node.childNodes[0] : '';
|
|
731
771
|
var secondChild = node.childNodes[1] ? node.childNodes[1] : '';
|
|
@@ -733,38 +773,80 @@ var mover = function (handlerApi) {
|
|
|
733
773
|
var dataSecondChild = secondChild ? serialize.visitNode(secondChild, '') : null;
|
|
734
774
|
if (secondChild && secondChild.kind === 'mo') {
|
|
735
775
|
var t = dataSecondChild.ascii;
|
|
736
|
-
var
|
|
737
|
-
if (
|
|
738
|
-
|
|
739
|
-
res = (0, common_1.AddToAsciiData)(res,
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
776
|
+
var data = (0, exports.FindSymbolToAM)('mover', t, (0, exports.getAttributes)(secondChild));
|
|
777
|
+
if (data.ascii) {
|
|
778
|
+
var linear = (0, helperLinear_1.formatLinearFromAscii)(data.ascii, dataFirstChild === null || dataFirstChild === void 0 ? void 0 : dataFirstChild.linear);
|
|
779
|
+
res = (0, common_1.AddToAsciiData)(res, { ascii: ' ', linear: '' });
|
|
780
|
+
res = (0, common_1.AddToAsciiData)(res, {
|
|
781
|
+
ascii: data.ascii,
|
|
782
|
+
linear: linear ? '' : data.linear,
|
|
783
|
+
});
|
|
784
|
+
res = (0, common_1.AddToAsciiData)(res, {
|
|
785
|
+
ascii: '(',
|
|
786
|
+
linear: !linear && ((_b = (_a = dataFirstChild === null || dataFirstChild === void 0 ? void 0 : dataFirstChild.linear) === null || _a === void 0 ? void 0 : _a.trim()) === null || _b === void 0 ? void 0 : _b.length) > 1 ? '(' : '',
|
|
787
|
+
});
|
|
788
|
+
res = (0, common_1.AddToAsciiData)(res, {
|
|
789
|
+
ascii: dataFirstChild ? dataFirstChild.ascii ? dataFirstChild.ascii.trim() : dataFirstChild.ascii : '',
|
|
790
|
+
linear: linear ? linear : dataFirstChild ? dataFirstChild.linear ? dataFirstChild.linear.trim() : dataFirstChild.linear : '',
|
|
791
|
+
ascii_tsv: dataFirstChild ? dataFirstChild.ascii_tsv ? dataFirstChild.ascii_tsv.trim() : dataFirstChild.ascii_tsv : '',
|
|
792
|
+
ascii_csv: dataFirstChild ? dataFirstChild.ascii_csv ? dataFirstChild.ascii_csv.trim() : dataFirstChild.ascii_csv : '',
|
|
793
|
+
ascii_md: dataFirstChild ? dataFirstChild.ascii_md ? dataFirstChild.ascii_md.trim() : dataFirstChild.ascii_md : ''
|
|
794
|
+
});
|
|
795
|
+
res = (0, common_1.AddToAsciiData)(res, {
|
|
796
|
+
ascii: ')',
|
|
797
|
+
linear: !linear && ((_d = (_c = dataFirstChild === null || dataFirstChild === void 0 ? void 0 : dataFirstChild.linear) === null || _c === void 0 ? void 0 : _c.trim()) === null || _d === void 0 ? void 0 : _d.length) > 1 ? ')' : ''
|
|
798
|
+
});
|
|
746
799
|
}
|
|
747
800
|
else {
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
dataFirstChild ? dataFirstChild.
|
|
751
|
-
dataFirstChild ? dataFirstChild.
|
|
752
|
-
dataFirstChild ? dataFirstChild.
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
res = (0, common_1.AddToAsciiData)(res,
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
801
|
+
var linear = (0, helperLinear_1.formatLinearFromAscii)(data.linear, dataFirstChild === null || dataFirstChild === void 0 ? void 0 : dataFirstChild.linear, 'mover');
|
|
802
|
+
res = (0, common_1.AddToAsciiData)(res, {
|
|
803
|
+
ascii: dataFirstChild ? dataFirstChild.ascii : '',
|
|
804
|
+
linear: !linear && dataFirstChild ? dataFirstChild.linear : '',
|
|
805
|
+
ascii_tsv: dataFirstChild ? dataFirstChild.ascii_tsv : '',
|
|
806
|
+
ascii_csv: dataFirstChild ? dataFirstChild.ascii_csv : '',
|
|
807
|
+
ascii_md: dataFirstChild ? dataFirstChild.ascii_md : ''
|
|
808
|
+
});
|
|
809
|
+
res = (0, common_1.AddToAsciiData)(res, {
|
|
810
|
+
ascii: '^',
|
|
811
|
+
linear: linear ? linear : '^'
|
|
812
|
+
});
|
|
813
|
+
res = (0, common_1.AddToAsciiData)(res, {
|
|
814
|
+
ascii: serialize.options.extraBrackets ? '(' : '',
|
|
815
|
+
linear: !linear && ((_e = dataSecondChild === null || dataSecondChild === void 0 ? void 0 : dataSecondChild.linear) === null || _e === void 0 ? void 0 : _e.length) ? '(' : '',
|
|
816
|
+
});
|
|
817
|
+
res = (0, common_1.AddToAsciiData)(res, {
|
|
818
|
+
ascii: dataSecondChild ? dataSecondChild.ascii : '',
|
|
819
|
+
linear: !linear && dataSecondChild ? dataSecondChild.linear : '',
|
|
820
|
+
ascii_tsv: dataSecondChild ? dataSecondChild.ascii_tsv : '',
|
|
821
|
+
ascii_csv: dataSecondChild ? dataSecondChild.ascii_csv : '',
|
|
822
|
+
ascii_md: dataSecondChild ? dataSecondChild.ascii_md : ''
|
|
823
|
+
});
|
|
824
|
+
res = (0, common_1.AddToAsciiData)(res, {
|
|
825
|
+
ascii: serialize.options.extraBrackets ? ')' : '',
|
|
826
|
+
linear: !linear && ((_f = dataSecondChild === null || dataSecondChild === void 0 ? void 0 : dataSecondChild.linear) === null || _f === void 0 ? void 0 : _f.length) ? ')' : '',
|
|
827
|
+
});
|
|
763
828
|
}
|
|
764
829
|
}
|
|
765
830
|
else {
|
|
766
831
|
var data = handlerApi.handleAll(node, serialize);
|
|
767
|
-
|
|
832
|
+
var linear = '';
|
|
833
|
+
if (((_g = dataFirstChild === null || dataFirstChild === void 0 ? void 0 : dataFirstChild.linear) === null || _g === void 0 ? void 0 : _g.length) && ((_h = dataSecondChild.linear) === null || _h === void 0 ? void 0 : _h.length)) {
|
|
834
|
+
linear += ((_j = dataFirstChild.linear) === null || _j === void 0 ? void 0 : _j.length) > 1 ? "(".concat(dataFirstChild.linear, ")") : dataFirstChild.linear;
|
|
835
|
+
var linearData = dataSecondChild.linear.length === 1 ? (0, helperLinear_1.findAmSymbolsToLinear)(dataSecondChild.linear) : null;
|
|
836
|
+
if (linearData) {
|
|
837
|
+
linear += dataFirstChild.linear.length > 1 ? linearData.outputComplex : linearData.output;
|
|
838
|
+
}
|
|
839
|
+
else {
|
|
840
|
+
linear += '^';
|
|
841
|
+
linear += ((_k = dataSecondChild.linear) === null || _k === void 0 ? void 0 : _k.length) > 1 ? "(".concat(dataSecondChild.linear, ")") : dataSecondChild.linear;
|
|
842
|
+
}
|
|
843
|
+
}
|
|
844
|
+
if (linear) {
|
|
845
|
+
res = (0, common_1.AddToAsciiData)(res, tslib_1.__assign(tslib_1.__assign({}, data), { linear: linear }));
|
|
846
|
+
}
|
|
847
|
+
else {
|
|
848
|
+
res = (0, common_1.AddToAsciiData)(res, data);
|
|
849
|
+
}
|
|
768
850
|
}
|
|
769
851
|
return res;
|
|
770
852
|
}
|
|
@@ -776,12 +858,8 @@ var mover = function (handlerApi) {
|
|
|
776
858
|
};
|
|
777
859
|
var munder = function (handlerApi) {
|
|
778
860
|
return function (node, serialize) {
|
|
779
|
-
var
|
|
780
|
-
|
|
781
|
-
ascii_tsv: '',
|
|
782
|
-
ascii_csv: '',
|
|
783
|
-
ascii_md: ''
|
|
784
|
-
};
|
|
861
|
+
var _a, _b;
|
|
862
|
+
var res = (0, common_1.initAsciiData)();
|
|
785
863
|
try {
|
|
786
864
|
var firstChild = node.childNodes[0] ? node.childNodes[0] : null;
|
|
787
865
|
var secondChild = node.childNodes[1] ? node.childNodes[1] : null;
|
|
@@ -789,38 +867,63 @@ var munder = function (handlerApi) {
|
|
|
789
867
|
var dataSecondChild = secondChild ? serialize.visitNode(secondChild, '') : null;
|
|
790
868
|
if (secondChild && secondChild.kind === 'mo') {
|
|
791
869
|
var t = dataSecondChild.ascii;
|
|
792
|
-
var
|
|
793
|
-
if (
|
|
794
|
-
|
|
795
|
-
res = (0, common_1.AddToAsciiData)(res,
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
870
|
+
var data = (0, exports.FindSymbolToAM)(node.kind, t);
|
|
871
|
+
if (data.ascii) {
|
|
872
|
+
var linear = (0, helperLinear_1.formatLinearFromAscii)(data.ascii, dataFirstChild === null || dataFirstChild === void 0 ? void 0 : dataFirstChild.linear);
|
|
873
|
+
res = (0, common_1.AddToAsciiData)(res, {
|
|
874
|
+
ascii: data.ascii + '(',
|
|
875
|
+
linear: linear ? linear : data.linear + '('
|
|
876
|
+
});
|
|
877
|
+
res = (0, common_1.AddToAsciiData)(res, {
|
|
878
|
+
ascii: dataFirstChild ? dataFirstChild.ascii : '',
|
|
879
|
+
linear: !linear && dataFirstChild ? dataFirstChild.linear : '',
|
|
880
|
+
ascii_tsv: dataFirstChild ? dataFirstChild.ascii_tsv : '',
|
|
881
|
+
ascii_csv: dataFirstChild ? dataFirstChild.ascii_csv : '',
|
|
882
|
+
ascii_md: dataFirstChild ? dataFirstChild.ascii_md : ''
|
|
883
|
+
});
|
|
884
|
+
res = (0, common_1.AddToAsciiData)(res, {
|
|
885
|
+
ascii: ')',
|
|
886
|
+
linear: !linear ? ')' : ''
|
|
887
|
+
});
|
|
802
888
|
}
|
|
803
889
|
else {
|
|
804
|
-
var
|
|
805
|
-
|
|
890
|
+
var data_2 = handlerApi.handleAll(node, serialize);
|
|
891
|
+
var linear = '';
|
|
892
|
+
if (((_a = dataFirstChild === null || dataFirstChild === void 0 ? void 0 : dataFirstChild.linear) === null || _a === void 0 ? void 0 : _a.length) && ((_b = dataSecondChild.linear) === null || _b === void 0 ? void 0 : _b.length)) {
|
|
893
|
+
linear = (0, helperLinear_1.formatLinearFromAscii)(dataSecondChild.linear, dataFirstChild.linear);
|
|
894
|
+
}
|
|
895
|
+
if (linear) {
|
|
896
|
+
res = (0, common_1.AddToAsciiData)(res, tslib_1.__assign(tslib_1.__assign({}, data_2), { linear: linear }));
|
|
897
|
+
}
|
|
898
|
+
else {
|
|
899
|
+
res = (0, common_1.AddToAsciiData)(res, data_2);
|
|
900
|
+
}
|
|
806
901
|
}
|
|
807
902
|
}
|
|
808
903
|
else {
|
|
809
|
-
res = (0, common_1.AddToAsciiData)(res,
|
|
810
|
-
dataFirstChild ? dataFirstChild.ascii : '',
|
|
811
|
-
dataFirstChild ? dataFirstChild.
|
|
812
|
-
dataFirstChild ? dataFirstChild.
|
|
813
|
-
dataFirstChild ? dataFirstChild.
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
res = (0, common_1.AddToAsciiData)(res,
|
|
817
|
-
res = (0, common_1.AddToAsciiData)(res,
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
904
|
+
res = (0, common_1.AddToAsciiData)(res, {
|
|
905
|
+
ascii: dataFirstChild ? dataFirstChild.ascii : '',
|
|
906
|
+
linear: dataFirstChild ? dataFirstChild.linear : '',
|
|
907
|
+
ascii_tsv: dataFirstChild ? dataFirstChild.ascii_tsv : '',
|
|
908
|
+
ascii_csv: dataFirstChild ? dataFirstChild.ascii_csv : '',
|
|
909
|
+
ascii_md: dataFirstChild ? dataFirstChild.ascii_md : ''
|
|
910
|
+
});
|
|
911
|
+
res = (0, common_1.AddToAsciiData)(res, { ascii: '_', linear: '_' });
|
|
912
|
+
res = (0, common_1.AddToAsciiData)(res, {
|
|
913
|
+
ascii: serialize.options.extraBrackets ? '(' : '',
|
|
914
|
+
linear: serialize.options.extraBrackets ? '(' : '',
|
|
915
|
+
});
|
|
916
|
+
res = (0, common_1.AddToAsciiData)(res, {
|
|
917
|
+
ascii: dataSecondChild ? dataSecondChild.ascii : '',
|
|
918
|
+
linear: dataSecondChild ? dataSecondChild.linear : '',
|
|
919
|
+
ascii_tsv: dataSecondChild ? dataSecondChild.ascii_tsv : '',
|
|
920
|
+
ascii_csv: dataSecondChild ? dataSecondChild.ascii_csv : '',
|
|
921
|
+
ascii_md: dataSecondChild ? dataSecondChild.ascii_md : ''
|
|
922
|
+
});
|
|
923
|
+
res = (0, common_1.AddToAsciiData)(res, {
|
|
924
|
+
ascii: serialize.options.extraBrackets ? ')' : '',
|
|
925
|
+
linear: serialize.options.extraBrackets ? ')' : '',
|
|
926
|
+
});
|
|
824
927
|
}
|
|
825
928
|
return res;
|
|
826
929
|
}
|
|
@@ -832,12 +935,8 @@ var munder = function (handlerApi) {
|
|
|
832
935
|
};
|
|
833
936
|
var munderover = function () {
|
|
834
937
|
return function (node, serialize) {
|
|
835
|
-
var
|
|
836
|
-
|
|
837
|
-
ascii_tsv: '',
|
|
838
|
-
ascii_csv: '',
|
|
839
|
-
ascii_md: ''
|
|
840
|
-
};
|
|
938
|
+
var _a, _b;
|
|
939
|
+
var res = (0, common_1.initAsciiData)();
|
|
841
940
|
try {
|
|
842
941
|
var firstChild = node.childNodes[0] ? node.childNodes[0] : null;
|
|
843
942
|
var secondChild = node.childNodes[1] ? node.childNodes[1] : null;
|
|
@@ -845,30 +944,56 @@ var munderover = function () {
|
|
|
845
944
|
var dataFirstChild = firstChild ? serialize.visitNode(firstChild, '') : null;
|
|
846
945
|
var dataSecondChild = secondChild ? serialize.visitNode(secondChild, '') : null;
|
|
847
946
|
var dataThirdChild = thirdChild ? serialize.visitNode(thirdChild, '') : null;
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
res = (0, common_1.AddToAsciiData)(res,
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
947
|
+
var linearNeedsParens = (dataFirstChild === null || dataFirstChild === void 0 ? void 0 : dataFirstChild.linear) && (0, helperLinear_1.hasAnyWhitespace)(dataFirstChild.linear);
|
|
948
|
+
res = (0, common_1.AddToAsciiData)(res, {
|
|
949
|
+
ascii: '',
|
|
950
|
+
linear: linearNeedsParens ? '(' : ''
|
|
951
|
+
});
|
|
952
|
+
res = (0, common_1.AddToAsciiData)(res, {
|
|
953
|
+
ascii: dataFirstChild.ascii ? dataFirstChild.ascii : '',
|
|
954
|
+
linear: dataFirstChild.linear ? (0, helperLinear_1.replaceUnicodeWhitespace)(dataFirstChild.linear) : '',
|
|
955
|
+
ascii_tsv: dataFirstChild.ascii_tsv ? dataFirstChild.ascii_tsv : '',
|
|
956
|
+
ascii_csv: dataFirstChild.ascii_csv ? dataFirstChild.ascii_csv : '',
|
|
957
|
+
ascii_md: dataFirstChild.ascii_md ? dataFirstChild.ascii_md : ''
|
|
958
|
+
});
|
|
959
|
+
res = (0, common_1.AddToAsciiData)(res, {
|
|
960
|
+
ascii: '',
|
|
961
|
+
linear: linearNeedsParens ? ')' : ''
|
|
962
|
+
});
|
|
963
|
+
res = (0, common_1.AddToAsciiData)(res, { ascii: '_', linear: '_' });
|
|
964
|
+
linearNeedsParens = ((_a = dataSecondChild === null || dataSecondChild === void 0 ? void 0 : dataSecondChild.linear) === null || _a === void 0 ? void 0 : _a.length) > 1 && !(0, helperLinear_1.isWrappedWithParens)(dataSecondChild.linear);
|
|
965
|
+
res = (0, common_1.AddToAsciiData)(res, {
|
|
966
|
+
ascii: serialize.options.extraBrackets ? '(' : '',
|
|
967
|
+
linear: linearNeedsParens ? '(' : '',
|
|
968
|
+
});
|
|
969
|
+
res = (0, common_1.AddToAsciiData)(res, {
|
|
970
|
+
ascii: dataSecondChild.ascii ? dataSecondChild.ascii : '',
|
|
971
|
+
linear: dataSecondChild.linear ? dataSecondChild.linear : '',
|
|
972
|
+
ascii_tsv: dataSecondChild.ascii_tsv ? dataSecondChild.ascii_tsv : '',
|
|
973
|
+
ascii_csv: dataSecondChild.ascii_csv ? dataSecondChild.ascii_csv : '',
|
|
974
|
+
ascii_md: dataSecondChild.ascii_md ? dataSecondChild.ascii_md : ''
|
|
975
|
+
});
|
|
976
|
+
res = (0, common_1.AddToAsciiData)(res, {
|
|
977
|
+
ascii: serialize.options.extraBrackets ? ')' : '',
|
|
978
|
+
linear: linearNeedsParens ? ')' : '',
|
|
979
|
+
});
|
|
980
|
+
res = (0, common_1.AddToAsciiData)(res, { ascii: '^', linear: '^' });
|
|
981
|
+
linearNeedsParens = ((_b = dataThirdChild === null || dataThirdChild === void 0 ? void 0 : dataThirdChild.linear) === null || _b === void 0 ? void 0 : _b.length) > 1 && !(0, helperLinear_1.isWrappedWithParens)(dataThirdChild.linear);
|
|
982
|
+
res = (0, common_1.AddToAsciiData)(res, {
|
|
983
|
+
ascii: serialize.options.extraBrackets ? '(' : '',
|
|
984
|
+
linear: linearNeedsParens ? '(' : '',
|
|
985
|
+
});
|
|
986
|
+
res = (0, common_1.AddToAsciiData)(res, {
|
|
987
|
+
ascii: dataThirdChild.ascii ? dataThirdChild.ascii : '',
|
|
988
|
+
linear: dataThirdChild.linear ? dataThirdChild.linear : '',
|
|
989
|
+
ascii_tsv: dataThirdChild.ascii_tsv ? dataThirdChild.ascii_tsv : '',
|
|
990
|
+
ascii_csv: dataThirdChild.ascii_csv ? dataThirdChild.ascii_csv : '',
|
|
991
|
+
ascii_md: dataThirdChild.ascii_md ? dataThirdChild.ascii_md : ''
|
|
992
|
+
});
|
|
993
|
+
res = (0, common_1.AddToAsciiData)(res, {
|
|
994
|
+
ascii: serialize.options.extraBrackets ? ')' : '',
|
|
995
|
+
linear: linearNeedsParens ? ')' : '',
|
|
996
|
+
});
|
|
872
997
|
return res;
|
|
873
998
|
}
|
|
874
999
|
catch (e) {
|
|
@@ -879,32 +1004,41 @@ var munderover = function () {
|
|
|
879
1004
|
};
|
|
880
1005
|
var msub = function () {
|
|
881
1006
|
return function (node, serialize) {
|
|
882
|
-
var
|
|
883
|
-
|
|
884
|
-
ascii_tsv: '',
|
|
885
|
-
ascii_csv: '',
|
|
886
|
-
ascii_md: ''
|
|
887
|
-
};
|
|
1007
|
+
var _a;
|
|
1008
|
+
var res = (0, common_1.initAsciiData)();
|
|
888
1009
|
try {
|
|
889
1010
|
var firstChild = node.childNodes[0] ? node.childNodes[0] : null;
|
|
890
1011
|
var secondChild = node.childNodes[1] ? node.childNodes[1] : null;
|
|
891
1012
|
var dataFirstChild = firstChild ? serialize.visitNode(firstChild, '') : null;
|
|
892
1013
|
var dataSecondChild = secondChild ? serialize.visitNode(secondChild, '') : null;
|
|
893
|
-
res = (0, common_1.AddToAsciiData)(res,
|
|
894
|
-
dataFirstChild ? dataFirstChild.ascii : '',
|
|
895
|
-
dataFirstChild ? dataFirstChild.
|
|
896
|
-
dataFirstChild ? dataFirstChild.
|
|
897
|
-
dataFirstChild ? dataFirstChild.
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
res = (0, common_1.AddToAsciiData)(res,
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
1014
|
+
res = (0, common_1.AddToAsciiData)(res, {
|
|
1015
|
+
ascii: dataFirstChild ? dataFirstChild.ascii : '',
|
|
1016
|
+
linear: dataFirstChild ? dataFirstChild.linear : '',
|
|
1017
|
+
ascii_tsv: dataFirstChild ? dataFirstChild.ascii_tsv : '',
|
|
1018
|
+
ascii_csv: dataFirstChild ? dataFirstChild.ascii_csv : '',
|
|
1019
|
+
ascii_md: dataFirstChild ? dataFirstChild.ascii_md : ''
|
|
1020
|
+
});
|
|
1021
|
+
var linear = (0, helperLinear_1.replaceScripts)(dataSecondChild === null || dataSecondChild === void 0 ? void 0 : dataSecondChild.linear, 'sub');
|
|
1022
|
+
res = (0, common_1.AddToAsciiData)(res, {
|
|
1023
|
+
ascii: '_',
|
|
1024
|
+
linear: linear ? linear : '_'
|
|
1025
|
+
});
|
|
1026
|
+
var linearNeedsParens = !linear && ((_a = dataSecondChild === null || dataSecondChild === void 0 ? void 0 : dataSecondChild.linear) === null || _a === void 0 ? void 0 : _a.length) > 1 && !(0, helperLinear_1.isWrappedWithParens)(dataSecondChild.linear);
|
|
1027
|
+
res = (0, common_1.AddToAsciiData)(res, {
|
|
1028
|
+
ascii: serialize.options.extraBrackets ? '(' : '',
|
|
1029
|
+
linear: linearNeedsParens ? '(' : '',
|
|
1030
|
+
});
|
|
1031
|
+
res = (0, common_1.AddToAsciiData)(res, {
|
|
1032
|
+
ascii: dataSecondChild ? dataSecondChild.ascii : '',
|
|
1033
|
+
linear: !linear && dataSecondChild ? dataSecondChild.linear : '',
|
|
1034
|
+
ascii_tsv: dataSecondChild ? dataSecondChild.ascii_tsv : '',
|
|
1035
|
+
ascii_csv: dataSecondChild ? dataSecondChild.ascii_csv : '',
|
|
1036
|
+
ascii_md: dataSecondChild ? dataSecondChild.ascii_md : ''
|
|
1037
|
+
});
|
|
1038
|
+
res = (0, common_1.AddToAsciiData)(res, {
|
|
1039
|
+
ascii: serialize.options.extraBrackets ? ')' : '',
|
|
1040
|
+
linear: linearNeedsParens ? ')' : '',
|
|
1041
|
+
});
|
|
908
1042
|
return res;
|
|
909
1043
|
}
|
|
910
1044
|
catch (e) {
|
|
@@ -915,12 +1049,8 @@ var msub = function () {
|
|
|
915
1049
|
};
|
|
916
1050
|
var msup = function () {
|
|
917
1051
|
return function (node, serialize) {
|
|
918
|
-
var
|
|
919
|
-
|
|
920
|
-
ascii_tsv: '',
|
|
921
|
-
ascii_csv: '',
|
|
922
|
-
ascii_md: ''
|
|
923
|
-
};
|
|
1052
|
+
var _a, _b;
|
|
1053
|
+
var res = (0, common_1.initAsciiData)();
|
|
924
1054
|
try {
|
|
925
1055
|
var firstChild = node.childNodes[0] ? node.childNodes[0] : null;
|
|
926
1056
|
var secondChild = node.childNodes[1] ? node.childNodes[1] : null;
|
|
@@ -928,25 +1058,48 @@ var msup = function () {
|
|
|
928
1058
|
secondChild.attributes.setInherited('flattenSup', flattenSup);
|
|
929
1059
|
var dataFirstChild = firstChild ? serialize.visitNode(firstChild, '') : null;
|
|
930
1060
|
var dataSecondChild = secondChild ? serialize.visitNode(secondChild, '') : null;
|
|
931
|
-
res = (0, common_1.AddToAsciiData)(res,
|
|
932
|
-
dataFirstChild ? dataFirstChild.ascii : '',
|
|
933
|
-
dataFirstChild ? dataFirstChild.
|
|
934
|
-
dataFirstChild ? dataFirstChild.
|
|
935
|
-
dataFirstChild ? dataFirstChild.
|
|
936
|
-
|
|
937
|
-
|
|
1061
|
+
res = (0, common_1.AddToAsciiData)(res, {
|
|
1062
|
+
ascii: dataFirstChild ? dataFirstChild.ascii : '',
|
|
1063
|
+
linear: dataFirstChild ? dataFirstChild.linear : '',
|
|
1064
|
+
ascii_tsv: dataFirstChild ? dataFirstChild.ascii_tsv : '',
|
|
1065
|
+
ascii_csv: dataFirstChild ? dataFirstChild.ascii_csv : '',
|
|
1066
|
+
ascii_md: dataFirstChild ? dataFirstChild.ascii_md : ''
|
|
1067
|
+
});
|
|
1068
|
+
var linearData = ((_a = dataSecondChild === null || dataSecondChild === void 0 ? void 0 : dataSecondChild.linear) === null || _a === void 0 ? void 0 : _a.length) === 1
|
|
1069
|
+
? (0, helperLinear_1.findAmSymbolsToLinear)(dataSecondChild.linear, 'msup')
|
|
1070
|
+
: null;
|
|
1071
|
+
var linear = linearData ? linearData.output : '';
|
|
938
1072
|
var ignoreBrackets = node.attributes.get('ignoreBrackets');
|
|
939
1073
|
if (ignoreBrackets && !dataSecondChild.ascii) {
|
|
1074
|
+
res = (0, common_1.AddToAsciiData)(res, {
|
|
1075
|
+
ascii: '^',
|
|
1076
|
+
linear: linear ? linear : '^'
|
|
1077
|
+
});
|
|
940
1078
|
return res;
|
|
941
1079
|
}
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
1080
|
+
if (!linear) {
|
|
1081
|
+
linear = (0, helperLinear_1.replaceScripts)(dataSecondChild === null || dataSecondChild === void 0 ? void 0 : dataSecondChild.linear);
|
|
1082
|
+
}
|
|
1083
|
+
var linearNeedsParens = !linear && ((_b = dataSecondChild === null || dataSecondChild === void 0 ? void 0 : dataSecondChild.linear) === null || _b === void 0 ? void 0 : _b.length) > 1 && !(0, helperLinear_1.isWrappedWithParens)(dataSecondChild.linear);
|
|
1084
|
+
res = (0, common_1.AddToAsciiData)(res, {
|
|
1085
|
+
ascii: '^',
|
|
1086
|
+
linear: linear ? linear : '^'
|
|
1087
|
+
});
|
|
1088
|
+
res = (0, common_1.AddToAsciiData)(res, {
|
|
1089
|
+
ascii: serialize.options.extraBrackets ? '(' : '',
|
|
1090
|
+
linear: linearNeedsParens ? '(' : '',
|
|
1091
|
+
});
|
|
1092
|
+
res = (0, common_1.AddToAsciiData)(res, {
|
|
1093
|
+
ascii: dataSecondChild ? dataSecondChild.ascii : '',
|
|
1094
|
+
linear: !linear && dataSecondChild ? dataSecondChild.linear : '',
|
|
1095
|
+
ascii_tsv: dataSecondChild ? dataSecondChild.ascii_tsv : '',
|
|
1096
|
+
ascii_csv: dataSecondChild ? dataSecondChild.ascii_csv : '',
|
|
1097
|
+
ascii_md: dataSecondChild ? dataSecondChild.ascii_md : ''
|
|
1098
|
+
});
|
|
1099
|
+
res = (0, common_1.AddToAsciiData)(res, {
|
|
1100
|
+
ascii: serialize.options.extraBrackets ? ')' : '',
|
|
1101
|
+
linear: linearNeedsParens ? ')' : '',
|
|
1102
|
+
});
|
|
950
1103
|
return res;
|
|
951
1104
|
}
|
|
952
1105
|
catch (e) {
|
|
@@ -957,12 +1110,8 @@ var msup = function () {
|
|
|
957
1110
|
};
|
|
958
1111
|
var msubsup = function () {
|
|
959
1112
|
return function (node, serialize) {
|
|
960
|
-
var
|
|
961
|
-
|
|
962
|
-
ascii_tsv: '',
|
|
963
|
-
ascii_csv: '',
|
|
964
|
-
ascii_md: ''
|
|
965
|
-
};
|
|
1113
|
+
var _a, _b;
|
|
1114
|
+
var res = (0, common_1.initAsciiData)();
|
|
966
1115
|
try {
|
|
967
1116
|
var firstChild = node.childNodes[0] ? node.childNodes[0] : null;
|
|
968
1117
|
var secondChild = node.childNodes[1] ? node.childNodes[1] : null;
|
|
@@ -970,30 +1119,64 @@ var msubsup = function () {
|
|
|
970
1119
|
var dataFirstChild = firstChild ? serialize.visitNode(firstChild, '') : null;
|
|
971
1120
|
var dataSecondChild = secondChild ? serialize.visitNode(secondChild, '') : null;
|
|
972
1121
|
var dataThirdChild = thirdChild ? serialize.visitNode(thirdChild, '') : null;
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
res = (0, common_1.AddToAsciiData)(res,
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
1122
|
+
var linearNeedsParens = (dataFirstChild === null || dataFirstChild === void 0 ? void 0 : dataFirstChild.linear) && (0, helperLinear_1.hasAnyWhitespace)(dataFirstChild.linear);
|
|
1123
|
+
res = (0, common_1.AddToAsciiData)(res, {
|
|
1124
|
+
ascii: '',
|
|
1125
|
+
linear: linearNeedsParens ? '(' : ''
|
|
1126
|
+
});
|
|
1127
|
+
res = (0, common_1.AddToAsciiData)(res, {
|
|
1128
|
+
ascii: dataFirstChild ? dataFirstChild.ascii : '',
|
|
1129
|
+
linear: (dataFirstChild === null || dataFirstChild === void 0 ? void 0 : dataFirstChild.linear) ? (0, helperLinear_1.replaceUnicodeWhitespace)(dataFirstChild.linear) : '',
|
|
1130
|
+
ascii_tsv: dataFirstChild ? dataFirstChild.ascii_tsv : '',
|
|
1131
|
+
ascii_csv: dataFirstChild ? dataFirstChild.ascii_csv : '',
|
|
1132
|
+
ascii_md: dataFirstChild ? dataFirstChild.ascii_md : ''
|
|
1133
|
+
});
|
|
1134
|
+
res = (0, common_1.AddToAsciiData)(res, {
|
|
1135
|
+
ascii: '',
|
|
1136
|
+
linear: linearNeedsParens ? ')' : ''
|
|
1137
|
+
});
|
|
1138
|
+
var linear = (0, helperLinear_1.replaceScripts)(dataSecondChild === null || dataSecondChild === void 0 ? void 0 : dataSecondChild.linear, 'sub');
|
|
1139
|
+
res = (0, common_1.AddToAsciiData)(res, {
|
|
1140
|
+
ascii: '_',
|
|
1141
|
+
linear: linear ? linear : '_'
|
|
1142
|
+
});
|
|
1143
|
+
linearNeedsParens = !linear && ((_a = dataSecondChild === null || dataSecondChild === void 0 ? void 0 : dataSecondChild.linear) === null || _a === void 0 ? void 0 : _a.length) > 1 && !(0, helperLinear_1.isWrappedWithParens)(dataSecondChild.linear);
|
|
1144
|
+
res = (0, common_1.AddToAsciiData)(res, {
|
|
1145
|
+
ascii: '(',
|
|
1146
|
+
linear: linearNeedsParens ? '(' : ''
|
|
1147
|
+
});
|
|
1148
|
+
res = (0, common_1.AddToAsciiData)(res, {
|
|
1149
|
+
ascii: dataSecondChild ? dataSecondChild.ascii : '',
|
|
1150
|
+
linear: !linear && dataSecondChild ? dataSecondChild.linear : '',
|
|
1151
|
+
ascii_tsv: dataSecondChild ? dataSecondChild.ascii_tsv : '',
|
|
1152
|
+
ascii_csv: dataSecondChild ? dataSecondChild.ascii_csv : '',
|
|
1153
|
+
ascii_md: dataSecondChild ? dataSecondChild.ascii_md : ''
|
|
1154
|
+
});
|
|
1155
|
+
res = (0, common_1.AddToAsciiData)(res, {
|
|
1156
|
+
ascii: ')',
|
|
1157
|
+
linear: linearNeedsParens ? ')' : ''
|
|
1158
|
+
});
|
|
1159
|
+
linear = (0, helperLinear_1.replaceScripts)(dataThirdChild === null || dataThirdChild === void 0 ? void 0 : dataThirdChild.linear);
|
|
1160
|
+
res = (0, common_1.AddToAsciiData)(res, {
|
|
1161
|
+
ascii: '^',
|
|
1162
|
+
linear: linear ? linear : '^'
|
|
1163
|
+
});
|
|
1164
|
+
linearNeedsParens = !linear && ((_b = dataThirdChild === null || dataThirdChild === void 0 ? void 0 : dataThirdChild.linear) === null || _b === void 0 ? void 0 : _b.length) > 1 && !(0, helperLinear_1.isWrappedWithParens)(dataThirdChild.linear);
|
|
1165
|
+
res = (0, common_1.AddToAsciiData)(res, {
|
|
1166
|
+
ascii: '(',
|
|
1167
|
+
linear: linearNeedsParens ? '(' : ''
|
|
1168
|
+
});
|
|
1169
|
+
res = (0, common_1.AddToAsciiData)(res, {
|
|
1170
|
+
ascii: dataThirdChild ? dataThirdChild.ascii : '',
|
|
1171
|
+
linear: !linear && dataThirdChild ? dataThirdChild.linear : '',
|
|
1172
|
+
ascii_tsv: dataThirdChild ? dataThirdChild.ascii_tsv : '',
|
|
1173
|
+
ascii_csv: dataThirdChild ? dataThirdChild.ascii_csv : '',
|
|
1174
|
+
ascii_md: dataThirdChild ? dataThirdChild.ascii_md : ''
|
|
1175
|
+
});
|
|
1176
|
+
res = (0, common_1.AddToAsciiData)(res, {
|
|
1177
|
+
ascii: ')',
|
|
1178
|
+
linear: linearNeedsParens ? ')' : ''
|
|
1179
|
+
});
|
|
997
1180
|
return res;
|
|
998
1181
|
}
|
|
999
1182
|
catch (e) {
|
|
@@ -1004,22 +1187,21 @@ var msubsup = function () {
|
|
|
1004
1187
|
};
|
|
1005
1188
|
var msqrt = function () {
|
|
1006
1189
|
return function (node, serialize) {
|
|
1007
|
-
var res =
|
|
1008
|
-
ascii: '',
|
|
1009
|
-
ascii_tsv: '',
|
|
1010
|
-
ascii_csv: '',
|
|
1011
|
-
ascii_md: ''
|
|
1012
|
-
};
|
|
1190
|
+
var res = (0, common_1.initAsciiData)();
|
|
1013
1191
|
try {
|
|
1014
1192
|
var firstChild = node.childNodes[0] ? node.childNodes[0] : null;
|
|
1015
1193
|
var dataFirstChild = firstChild ? serialize.visitNode(firstChild, '') : null;
|
|
1016
|
-
res = (0, common_1.AddToAsciiData)(res,
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
dataFirstChild ? dataFirstChild.
|
|
1022
|
-
|
|
1194
|
+
res = (0, common_1.AddToAsciiData)(res, {
|
|
1195
|
+
ascii: 'sqrt',
|
|
1196
|
+
linear: '√'
|
|
1197
|
+
});
|
|
1198
|
+
res = (0, common_1.AddToAsciiData)(res, {
|
|
1199
|
+
ascii: dataFirstChild ? dataFirstChild.ascii : '',
|
|
1200
|
+
linear: dataFirstChild ? dataFirstChild.linear : '',
|
|
1201
|
+
ascii_tsv: dataFirstChild ? dataFirstChild.ascii_tsv : '',
|
|
1202
|
+
ascii_csv: dataFirstChild ? dataFirstChild.ascii_csv : '',
|
|
1203
|
+
ascii_md: dataFirstChild ? dataFirstChild.ascii_md : ''
|
|
1204
|
+
});
|
|
1023
1205
|
return res;
|
|
1024
1206
|
}
|
|
1025
1207
|
catch (e) {
|
|
@@ -1030,34 +1212,48 @@ var msqrt = function () {
|
|
|
1030
1212
|
};
|
|
1031
1213
|
var mroot = function () {
|
|
1032
1214
|
return function (node, serialize) {
|
|
1033
|
-
var
|
|
1034
|
-
|
|
1035
|
-
ascii_tsv: '',
|
|
1036
|
-
ascii_csv: '',
|
|
1037
|
-
ascii_md: ''
|
|
1038
|
-
};
|
|
1215
|
+
var _a, _b;
|
|
1216
|
+
var res = (0, common_1.initAsciiData)();
|
|
1039
1217
|
try {
|
|
1040
1218
|
var firstChild = node.childNodes[0] ? node.childNodes[0] : null;
|
|
1041
1219
|
var secondChild = node.childNodes[1] ? node.childNodes[1] : null;
|
|
1042
1220
|
var dataSecondChild = secondChild ? serialize.visitNode(secondChild, '') : null;
|
|
1043
1221
|
var dataFirstChild = firstChild ? serialize.visitNode(firstChild, '') : null;
|
|
1044
|
-
|
|
1045
|
-
res = (0, common_1.AddToAsciiData)(res,
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
res = (0, common_1.AddToAsciiData)(res,
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
res = (0, common_1.AddToAsciiData)(res,
|
|
1222
|
+
var linear = (0, helperLinear_1.findRootSymbol)(dataSecondChild === null || dataSecondChild === void 0 ? void 0 : dataSecondChild.linear);
|
|
1223
|
+
res = (0, common_1.AddToAsciiData)(res, {
|
|
1224
|
+
ascii: 'root',
|
|
1225
|
+
linear: linear ? linear : 'root'
|
|
1226
|
+
});
|
|
1227
|
+
res = (0, common_1.AddToAsciiData)(res, {
|
|
1228
|
+
ascii: secondChild ? '(' : '',
|
|
1229
|
+
linear: linear ? '' : secondChild ? '(' : '',
|
|
1230
|
+
});
|
|
1231
|
+
res = (0, common_1.AddToAsciiData)(res, {
|
|
1232
|
+
ascii: dataSecondChild ? dataSecondChild.ascii : '',
|
|
1233
|
+
linear: linear ? '' : dataSecondChild ? dataSecondChild.linear : '',
|
|
1234
|
+
ascii_tsv: dataSecondChild ? dataSecondChild.ascii_tsv : '',
|
|
1235
|
+
ascii_csv: dataSecondChild ? dataSecondChild.ascii_csv : '',
|
|
1236
|
+
ascii_md: dataSecondChild ? dataSecondChild.ascii_md : ''
|
|
1237
|
+
});
|
|
1238
|
+
res = (0, common_1.AddToAsciiData)(res, {
|
|
1239
|
+
ascii: secondChild ? ')' : '',
|
|
1240
|
+
linear: linear ? '' : secondChild ? ')' : '',
|
|
1241
|
+
});
|
|
1242
|
+
res = (0, common_1.AddToAsciiData)(res, {
|
|
1243
|
+
ascii: firstChild ? '(' : '',
|
|
1244
|
+
linear: ((_a = dataFirstChild.linear) === null || _a === void 0 ? void 0 : _a.length) > 1 ? '(' : '',
|
|
1245
|
+
});
|
|
1246
|
+
res = (0, common_1.AddToAsciiData)(res, {
|
|
1247
|
+
ascii: dataFirstChild ? dataFirstChild.ascii : '',
|
|
1248
|
+
linear: dataFirstChild ? dataFirstChild.linear : '',
|
|
1249
|
+
ascii_tsv: dataFirstChild ? dataFirstChild.ascii_tsv : '',
|
|
1250
|
+
ascii_csv: dataFirstChild ? dataFirstChild.ascii_csv : '',
|
|
1251
|
+
ascii_md: dataFirstChild ? dataFirstChild.ascii_md : ''
|
|
1252
|
+
});
|
|
1253
|
+
res = (0, common_1.AddToAsciiData)(res, {
|
|
1254
|
+
ascii: firstChild ? ')' : '',
|
|
1255
|
+
linear: ((_b = dataFirstChild.linear) === null || _b === void 0 ? void 0 : _b.length) > 1 ? ')' : '',
|
|
1256
|
+
});
|
|
1061
1257
|
return res;
|
|
1062
1258
|
}
|
|
1063
1259
|
catch (e) {
|
|
@@ -1068,53 +1264,65 @@ var mroot = function () {
|
|
|
1068
1264
|
};
|
|
1069
1265
|
var mfrac = function () {
|
|
1070
1266
|
return function (node, serialize) {
|
|
1071
|
-
var
|
|
1072
|
-
|
|
1073
|
-
ascii_tsv: '',
|
|
1074
|
-
ascii_csv: '',
|
|
1075
|
-
ascii_md: ''
|
|
1076
|
-
};
|
|
1267
|
+
var _a, _b, _c, _d;
|
|
1268
|
+
var res = (0, common_1.initAsciiData)();
|
|
1077
1269
|
try {
|
|
1078
1270
|
var firstChild = node.childNodes[0] ? node.childNodes[0] : null;
|
|
1079
1271
|
var secondChild = node.childNodes[1] ? node.childNodes[1] : null;
|
|
1080
1272
|
var dataFirstChild = firstChild ? serialize.visitNode(firstChild, '') : null;
|
|
1081
1273
|
var dataSecondChild = secondChild ? serialize.visitNode(secondChild, '') : null;
|
|
1082
1274
|
if ((firstChild && firstChild.kind === "mrow" && firstChild.childNodes.length > 1) || serialize.options.extraBrackets) {
|
|
1083
|
-
res = (0, common_1.AddToAsciiData)(res,
|
|
1084
|
-
|
|
1085
|
-
dataFirstChild ?
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
dataFirstChild ? dataFirstChild.
|
|
1089
|
-
|
|
1090
|
-
|
|
1275
|
+
res = (0, common_1.AddToAsciiData)(res, {
|
|
1276
|
+
ascii: '(',
|
|
1277
|
+
linear: ((_a = dataFirstChild.linear) === null || _a === void 0 ? void 0 : _a.length) > 1 ? '(' : ''
|
|
1278
|
+
});
|
|
1279
|
+
res = (0, common_1.AddToAsciiData)(res, {
|
|
1280
|
+
ascii: dataFirstChild ? dataFirstChild.ascii : '',
|
|
1281
|
+
linear: dataFirstChild ? dataFirstChild.linear : '',
|
|
1282
|
+
ascii_tsv: dataFirstChild ? dataFirstChild.ascii_tsv : '',
|
|
1283
|
+
ascii_csv: dataFirstChild ? dataFirstChild.ascii_csv : '',
|
|
1284
|
+
ascii_md: dataFirstChild ? dataFirstChild.ascii_md : ''
|
|
1285
|
+
});
|
|
1286
|
+
res = (0, common_1.AddToAsciiData)(res, {
|
|
1287
|
+
ascii: ')',
|
|
1288
|
+
linear: ((_b = dataFirstChild.linear) === null || _b === void 0 ? void 0 : _b.length) > 1 ? ')' : ''
|
|
1289
|
+
});
|
|
1091
1290
|
}
|
|
1092
1291
|
else {
|
|
1093
|
-
res = (0, common_1.AddToAsciiData)(res,
|
|
1094
|
-
dataFirstChild ? dataFirstChild.ascii : '',
|
|
1095
|
-
dataFirstChild ? dataFirstChild.
|
|
1096
|
-
dataFirstChild ? dataFirstChild.
|
|
1097
|
-
dataFirstChild ? dataFirstChild.
|
|
1098
|
-
|
|
1292
|
+
res = (0, common_1.AddToAsciiData)(res, {
|
|
1293
|
+
ascii: dataFirstChild ? dataFirstChild.ascii : '',
|
|
1294
|
+
linear: dataFirstChild ? dataFirstChild.linear : '',
|
|
1295
|
+
ascii_tsv: dataFirstChild ? dataFirstChild.ascii_tsv : '',
|
|
1296
|
+
ascii_csv: dataFirstChild ? dataFirstChild.ascii_csv : '',
|
|
1297
|
+
ascii_md: dataFirstChild ? dataFirstChild.ascii_md : ''
|
|
1298
|
+
});
|
|
1099
1299
|
}
|
|
1100
|
-
res = (0, common_1.AddToAsciiData)(res,
|
|
1300
|
+
res = (0, common_1.AddToAsciiData)(res, { ascii: '/', linear: '/' });
|
|
1101
1301
|
if ((secondChild && secondChild.kind === "mrow" && secondChild.childNodes.length > 1) || serialize.options.extraBrackets) {
|
|
1102
|
-
res = (0, common_1.AddToAsciiData)(res,
|
|
1103
|
-
|
|
1104
|
-
dataSecondChild ?
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
dataSecondChild ? dataSecondChild.
|
|
1108
|
-
|
|
1109
|
-
|
|
1302
|
+
res = (0, common_1.AddToAsciiData)(res, {
|
|
1303
|
+
ascii: '(',
|
|
1304
|
+
linear: ((_c = dataSecondChild.linear) === null || _c === void 0 ? void 0 : _c.length) > 1 ? '(' : ''
|
|
1305
|
+
});
|
|
1306
|
+
res = (0, common_1.AddToAsciiData)(res, {
|
|
1307
|
+
ascii: dataSecondChild ? dataSecondChild.ascii : '',
|
|
1308
|
+
linear: dataSecondChild ? dataSecondChild.linear : '',
|
|
1309
|
+
ascii_tsv: dataSecondChild ? dataSecondChild.ascii_tsv : '',
|
|
1310
|
+
ascii_csv: dataSecondChild ? dataSecondChild.ascii_csv : '',
|
|
1311
|
+
ascii_md: dataSecondChild ? dataSecondChild.ascii_md : ''
|
|
1312
|
+
});
|
|
1313
|
+
res = (0, common_1.AddToAsciiData)(res, {
|
|
1314
|
+
ascii: ')',
|
|
1315
|
+
linear: ((_d = dataSecondChild.linear) === null || _d === void 0 ? void 0 : _d.length) > 1 ? ')' : ''
|
|
1316
|
+
});
|
|
1110
1317
|
}
|
|
1111
1318
|
else {
|
|
1112
|
-
res = (0, common_1.AddToAsciiData)(res,
|
|
1113
|
-
dataSecondChild ? dataSecondChild.ascii : '',
|
|
1114
|
-
dataSecondChild ? dataSecondChild.
|
|
1115
|
-
dataSecondChild ? dataSecondChild.
|
|
1116
|
-
dataSecondChild ? dataSecondChild.
|
|
1117
|
-
|
|
1319
|
+
res = (0, common_1.AddToAsciiData)(res, {
|
|
1320
|
+
ascii: dataSecondChild ? dataSecondChild.ascii : '',
|
|
1321
|
+
linear: dataSecondChild ? dataSecondChild.linear : '',
|
|
1322
|
+
ascii_tsv: dataSecondChild ? dataSecondChild.ascii_tsv : '',
|
|
1323
|
+
ascii_csv: dataSecondChild ? dataSecondChild.ascii_csv : '',
|
|
1324
|
+
ascii_md: dataSecondChild ? dataSecondChild.ascii_md : ''
|
|
1325
|
+
});
|
|
1118
1326
|
}
|
|
1119
1327
|
return res;
|
|
1120
1328
|
}
|
|
@@ -1126,51 +1334,51 @@ var mfrac = function () {
|
|
|
1126
1334
|
};
|
|
1127
1335
|
var mtext = function () {
|
|
1128
1336
|
return function (node, serialize) {
|
|
1129
|
-
var res =
|
|
1130
|
-
ascii: '',
|
|
1131
|
-
ascii_tsv: '',
|
|
1132
|
-
ascii_csv: '',
|
|
1133
|
-
ascii_md: ''
|
|
1134
|
-
};
|
|
1337
|
+
var res = (0, common_1.initAsciiData)();
|
|
1135
1338
|
try {
|
|
1136
1339
|
if (!node.childNodes || node.childNodes.length === 0) {
|
|
1137
1340
|
return res;
|
|
1138
1341
|
}
|
|
1139
1342
|
var firstChild = node.childNodes[0];
|
|
1140
1343
|
var value = (0, exports.FindSymbolReplace)(firstChild.text);
|
|
1141
|
-
var
|
|
1142
|
-
if (
|
|
1143
|
-
res = (0, common_1.AddToAsciiData)(res,
|
|
1344
|
+
var data = (0, exports.FindSymbolToAM)(node.kind, value);
|
|
1345
|
+
if (data.ascii) {
|
|
1346
|
+
res = (0, common_1.AddToAsciiData)(res, {
|
|
1347
|
+
ascii: data.ascii,
|
|
1348
|
+
linear: data.linear
|
|
1349
|
+
});
|
|
1144
1350
|
return res;
|
|
1145
1351
|
}
|
|
1146
1352
|
var toTsv = node.attributes.get('toTsv');
|
|
1147
1353
|
var toCsv = node.attributes.get('toCsv');
|
|
1148
1354
|
var toMd = node.attributes.get('toMd');
|
|
1149
1355
|
if (value[0] === '(' || toTsv || toCsv || toMd) {
|
|
1150
|
-
res = (0, common_1.AddToAsciiData)(res,
|
|
1151
|
-
value[0] === '(' ? value.replace(/"/g, '') : value,
|
|
1152
|
-
|
|
1153
|
-
|
|
1154
|
-
value
|
|
1155
|
-
|
|
1356
|
+
res = (0, common_1.AddToAsciiData)(res, {
|
|
1357
|
+
ascii: value[0] === '(' ? value.replace(/"/g, '') : value,
|
|
1358
|
+
linear: value[0] === '(' ? value.replace(/"/g, '') : value,
|
|
1359
|
+
ascii_tsv: toTsv ? value.replace(/"/g, '') : value,
|
|
1360
|
+
ascii_csv: toCsv ? value.replace(/"/g, '') : value,
|
|
1361
|
+
ascii_md: value
|
|
1362
|
+
});
|
|
1156
1363
|
}
|
|
1157
1364
|
else {
|
|
1158
1365
|
if (!value || (value && !value.trim())) {
|
|
1159
|
-
res = (0, common_1.AddToAsciiData)(res,
|
|
1366
|
+
res = (0, common_1.AddToAsciiData)(res, { ascii: '', linear: '' });
|
|
1160
1367
|
}
|
|
1161
1368
|
else {
|
|
1162
1369
|
/** For tsv/csv:
|
|
1163
1370
|
* Omit the " in nested arrays */
|
|
1164
|
-
res = (0, common_1.AddToAsciiData)(res,
|
|
1165
|
-
'"' + value + '"',
|
|
1166
|
-
|
|
1371
|
+
res = (0, common_1.AddToAsciiData)(res, {
|
|
1372
|
+
ascii: '"' + value + '"',
|
|
1373
|
+
linear: value,
|
|
1374
|
+
ascii_tsv: serialize.options.tableToTsv
|
|
1167
1375
|
? value.replace(/"/g, '')
|
|
1168
1376
|
: '"' + value + '"',
|
|
1169
|
-
serialize.options.tableToCsv
|
|
1377
|
+
ascii_csv: serialize.options.tableToCsv
|
|
1170
1378
|
? value.replace(/"/g, '')
|
|
1171
1379
|
: value,
|
|
1172
|
-
value
|
|
1173
|
-
|
|
1380
|
+
ascii_md: value
|
|
1381
|
+
});
|
|
1174
1382
|
}
|
|
1175
1383
|
}
|
|
1176
1384
|
return res;
|
|
@@ -1183,12 +1391,7 @@ var mtext = function () {
|
|
|
1183
1391
|
};
|
|
1184
1392
|
var mi = function () {
|
|
1185
1393
|
return function (node, serialize) {
|
|
1186
|
-
var res =
|
|
1187
|
-
ascii: '',
|
|
1188
|
-
ascii_tsv: '',
|
|
1189
|
-
ascii_csv: '',
|
|
1190
|
-
ascii_md: ''
|
|
1191
|
-
};
|
|
1394
|
+
var res = (0, common_1.initAsciiData)();
|
|
1192
1395
|
try {
|
|
1193
1396
|
if (!node.childNodes || node.childNodes.length === 0) {
|
|
1194
1397
|
return res;
|
|
@@ -1198,20 +1401,33 @@ var mi = function () {
|
|
|
1198
1401
|
var atr = serialize.options.showStyle
|
|
1199
1402
|
? (0, exports.getAttributes)(node)
|
|
1200
1403
|
: null;
|
|
1201
|
-
var
|
|
1202
|
-
if (
|
|
1203
|
-
var isFunction = helperA_1.regExpIsFunction.test(
|
|
1404
|
+
var data = (0, exports.SymbolToAM)(node.kind, value, atr);
|
|
1405
|
+
if (data.ascii && data.ascii.length > 1 && regW.test(data.ascii[0])) {
|
|
1406
|
+
var isFunction = helperA_1.regExpIsFunction.test(data.ascii.trim());
|
|
1204
1407
|
if (isFunction) {
|
|
1205
1408
|
node.Parent.attributes.setInherited('isFunction', isFunction);
|
|
1206
1409
|
}
|
|
1207
|
-
res = (0, common_1.AddToAsciiData)(res,
|
|
1208
|
-
|
|
1410
|
+
res = (0, common_1.AddToAsciiData)(res, {
|
|
1411
|
+
ascii: (0, exports.needFirstSpace)(node) ? ' ' : '',
|
|
1412
|
+
linear: (0, exports.needFirstSpace)(node, true) ? ' ' : ''
|
|
1413
|
+
});
|
|
1414
|
+
res = (0, common_1.AddToAsciiData)(res, {
|
|
1415
|
+
ascii: data.ascii,
|
|
1416
|
+
linear: data.linear || data.ascii
|
|
1417
|
+
});
|
|
1209
1418
|
var hasLastSpace = needLastSpace(node, isFunction);
|
|
1419
|
+
var hasLastSpaceLinear = needLastSpace(node, isFunction, true);
|
|
1210
1420
|
node.attributes.setInherited('hasLastSpace', hasLastSpace);
|
|
1211
|
-
res = (0, common_1.AddToAsciiData)(res,
|
|
1421
|
+
res = (0, common_1.AddToAsciiData)(res, {
|
|
1422
|
+
ascii: hasLastSpace ? ' ' : '',
|
|
1423
|
+
linear: hasLastSpaceLinear ? ' ' : ''
|
|
1424
|
+
});
|
|
1212
1425
|
}
|
|
1213
1426
|
else {
|
|
1214
|
-
res = (0, common_1.AddToAsciiData)(res,
|
|
1427
|
+
res = (0, common_1.AddToAsciiData)(res, {
|
|
1428
|
+
ascii: data.ascii,
|
|
1429
|
+
linear: data.linear || data.ascii
|
|
1430
|
+
});
|
|
1215
1431
|
}
|
|
1216
1432
|
return res;
|
|
1217
1433
|
}
|
|
@@ -1223,12 +1439,7 @@ var mi = function () {
|
|
|
1223
1439
|
};
|
|
1224
1440
|
var mo = function () {
|
|
1225
1441
|
return function (node, serialize) {
|
|
1226
|
-
var res =
|
|
1227
|
-
ascii: '',
|
|
1228
|
-
ascii_tsv: '',
|
|
1229
|
-
ascii_csv: '',
|
|
1230
|
-
ascii_md: ''
|
|
1231
|
-
};
|
|
1442
|
+
var res = (0, common_1.initAsciiData)();
|
|
1232
1443
|
try {
|
|
1233
1444
|
var value = getChildrenText(node);
|
|
1234
1445
|
var flattenSup = node.attributes.get('flattenSup');
|
|
@@ -1240,47 +1451,55 @@ var mo = function () {
|
|
|
1240
1451
|
return res;
|
|
1241
1452
|
}
|
|
1242
1453
|
var atr = (0, exports.getAttributes)(node);
|
|
1243
|
-
var
|
|
1244
|
-
if (
|
|
1245
|
-
res = (0, common_1.AddToAsciiData)(res,
|
|
1246
|
-
|
|
1247
|
-
|
|
1454
|
+
var data = (0, exports.SymbolToAM)(node.kind, value, atr, serialize.options.showStyle);
|
|
1455
|
+
if (data.ascii && data.ascii.length > 1) {
|
|
1456
|
+
res = (0, common_1.AddToAsciiData)(res, {
|
|
1457
|
+
ascii: regW.test(data.ascii[0]) && (0, exports.needFirstSpace)(node) ? ' ' : '',
|
|
1458
|
+
linear: regW.test(data.linear[0]) && (0, exports.needFirstSpace)(node) ? ' ' : ''
|
|
1459
|
+
});
|
|
1460
|
+
res = (0, common_1.AddToAsciiData)(res, {
|
|
1461
|
+
ascii: data.ascii,
|
|
1462
|
+
linear: data.linear || data.ascii
|
|
1463
|
+
});
|
|
1464
|
+
var isNeedLastSpace = needLastSpace(node);
|
|
1465
|
+
var hasLastSpace = regW.test(data.ascii[data.ascii.length - 1]) && isNeedLastSpace;
|
|
1466
|
+
var hasLastSpaceLinear = regW.test(data.linear[data.linear.length - 1]) && isNeedLastSpace;
|
|
1248
1467
|
node.attributes.setInherited('hasLastSpace', hasLastSpace);
|
|
1249
|
-
res = (0, common_1.AddToAsciiData)(res,
|
|
1468
|
+
res = (0, common_1.AddToAsciiData)(res, {
|
|
1469
|
+
ascii: hasLastSpace ? ' ' : '',
|
|
1470
|
+
linear: hasLastSpaceLinear ? ' ' : ''
|
|
1471
|
+
});
|
|
1250
1472
|
}
|
|
1251
1473
|
else {
|
|
1252
|
-
if (
|
|
1253
|
-
|
|
1474
|
+
if (data.ascii === "―" && node.Parent.kind === "munder") {
|
|
1475
|
+
data.ascii = "_";
|
|
1254
1476
|
}
|
|
1255
|
-
if (
|
|
1477
|
+
if (data.ascii === ',' && (node.Parent.kind === 'mtd' || (node.Parent.kind === 'TeXAtom' && node.Parent.Parent.kind === 'mtd'))) {
|
|
1256
1478
|
/** For tsv/csv:
|
|
1257
1479
|
* Omit the " in nested arrays */
|
|
1258
|
-
res = (0, common_1.AddToAsciiData)(res,
|
|
1259
|
-
'"' +
|
|
1260
|
-
|
|
1261
|
-
|
|
1262
|
-
|
|
1263
|
-
|
|
1480
|
+
res = (0, common_1.AddToAsciiData)(res, {
|
|
1481
|
+
ascii: '"' + data.ascii + '"',
|
|
1482
|
+
linear: data.linear,
|
|
1483
|
+
ascii_tsv: "".concat(serialize.options.tableToTsv ? data.ascii : '"' + data.ascii + '"'),
|
|
1484
|
+
ascii_csv: data.ascii,
|
|
1485
|
+
ascii_md: data.ascii
|
|
1486
|
+
});
|
|
1264
1487
|
}
|
|
1265
1488
|
else {
|
|
1266
|
-
res = (0, common_1.AddToAsciiData)(res,
|
|
1267
|
-
|
|
1268
|
-
|
|
1269
|
-
|
|
1270
|
-
|
|
1271
|
-
|
|
1489
|
+
res = (0, common_1.AddToAsciiData)(res, {
|
|
1490
|
+
ascii: data.ascii,
|
|
1491
|
+
linear: data.linear,
|
|
1492
|
+
ascii_tsv: data.ascii === '"' ? '' : data.ascii,
|
|
1493
|
+
ascii_csv: data.ascii === '"' ? '' : data.ascii,
|
|
1494
|
+
ascii_md: data.ascii
|
|
1495
|
+
});
|
|
1272
1496
|
}
|
|
1273
1497
|
}
|
|
1274
1498
|
if (node.Parent && node.Parent.kind === "mpadded" && node.Parent.Parent && node.Parent.Parent.kind === "menclose") {
|
|
1275
1499
|
var atr_1 = (0, exports.getAttributes)(node.Parent.Parent);
|
|
1276
1500
|
if (atr_1.notation && atr_1.notation.toString().indexOf("bottom") !== -1) {
|
|
1277
1501
|
node.Parent.Parent.attributes.attributes.lcm = true;
|
|
1278
|
-
return
|
|
1279
|
-
ascii: '',
|
|
1280
|
-
ascii_tsv: '',
|
|
1281
|
-
ascii_csv: '',
|
|
1282
|
-
ascii_md: ''
|
|
1283
|
-
};
|
|
1502
|
+
return (0, common_1.initAsciiData)();
|
|
1284
1503
|
}
|
|
1285
1504
|
}
|
|
1286
1505
|
return res;
|
|
@@ -1294,36 +1513,43 @@ var mo = function () {
|
|
|
1294
1513
|
var mspace = function (handlerApi) {
|
|
1295
1514
|
return function (node, serialize) {
|
|
1296
1515
|
var _a, _b;
|
|
1297
|
-
var res =
|
|
1298
|
-
ascii: '',
|
|
1299
|
-
ascii_tsv: '',
|
|
1300
|
-
ascii_csv: '',
|
|
1301
|
-
ascii_md: ''
|
|
1302
|
-
};
|
|
1516
|
+
var res = (0, common_1.initAsciiData)();
|
|
1303
1517
|
try {
|
|
1304
1518
|
var atr = (0, exports.getAttributes)(node);
|
|
1305
1519
|
if (atr && atr.width === "2em") {
|
|
1306
|
-
res = (0, common_1.AddToAsciiData)(res,
|
|
1307
|
-
|
|
1520
|
+
res = (0, common_1.AddToAsciiData)(res, {
|
|
1521
|
+
ascii: node.parent.parent && (0, exports.needFirstSpace)(node.parent.parent) ? ' ' : '',
|
|
1522
|
+
linear: node.parent.parent && (0, exports.needFirstSpace)(node.parent.parent) ? ' ' : ''
|
|
1523
|
+
});
|
|
1524
|
+
res = (0, common_1.AddToAsciiData)(res, { ascii: 'qquad', linear: ' ' });
|
|
1308
1525
|
if ((_a = node.parent) === null || _a === void 0 ? void 0 : _a.parent) {
|
|
1309
1526
|
var hasLastSpace = needLastSpace(node.parent.parent);
|
|
1310
1527
|
node.parent.parent.attributes.setInherited('hasLastSpace', hasLastSpace);
|
|
1311
|
-
res = (0, common_1.AddToAsciiData)(res,
|
|
1528
|
+
res = (0, common_1.AddToAsciiData)(res, {
|
|
1529
|
+
ascii: hasLastSpace ? ' ' : '',
|
|
1530
|
+
linear: hasLastSpace ? ' ' : ''
|
|
1531
|
+
});
|
|
1312
1532
|
}
|
|
1313
1533
|
return res;
|
|
1314
1534
|
}
|
|
1315
1535
|
if (atr && atr.width === "1em") {
|
|
1316
|
-
res = (0, common_1.AddToAsciiData)(res,
|
|
1317
|
-
|
|
1536
|
+
res = (0, common_1.AddToAsciiData)(res, {
|
|
1537
|
+
ascii: node.parent.parent && (0, exports.needFirstSpace)(node.parent.parent) ? ' ' : '',
|
|
1538
|
+
linear: node.parent.parent && (0, exports.needFirstSpace)(node.parent.parent) ? ' ' : ''
|
|
1539
|
+
});
|
|
1540
|
+
res = (0, common_1.AddToAsciiData)(res, { ascii: 'quad', linear: ' ' });
|
|
1318
1541
|
if ((_b = node.parent) === null || _b === void 0 ? void 0 : _b.parent) {
|
|
1319
1542
|
var hasLastSpace = needLastSpace(node.parent.parent);
|
|
1320
1543
|
node.parent.parent.attributes.setInherited('hasLastSpace', hasLastSpace);
|
|
1321
|
-
res = (0, common_1.AddToAsciiData)(res,
|
|
1544
|
+
res = (0, common_1.AddToAsciiData)(res, {
|
|
1545
|
+
ascii: hasLastSpace ? ' ' : '',
|
|
1546
|
+
linear: hasLastSpace ? ' ' : ''
|
|
1547
|
+
});
|
|
1322
1548
|
}
|
|
1323
1549
|
return res;
|
|
1324
1550
|
}
|
|
1325
1551
|
var data = handlerApi.handleAll(node, serialize);
|
|
1326
|
-
res = (0, common_1.AddToAsciiData)(res,
|
|
1552
|
+
res = (0, common_1.AddToAsciiData)(res, data);
|
|
1327
1553
|
return res;
|
|
1328
1554
|
}
|
|
1329
1555
|
catch (e) {
|
|
@@ -1334,23 +1560,21 @@ var mspace = function (handlerApi) {
|
|
|
1334
1560
|
};
|
|
1335
1561
|
var handle = function (node, serialize) {
|
|
1336
1562
|
var handler = handlers[node.kind] || defHandle;
|
|
1337
|
-
|
|
1563
|
+
var res = handler(node, serialize);
|
|
1564
|
+
node.currentData = res;
|
|
1565
|
+
return res;
|
|
1338
1566
|
};
|
|
1339
1567
|
exports.handle = handle;
|
|
1340
1568
|
var handleAll = function (node, serialize) {
|
|
1341
1569
|
var e_2, _a;
|
|
1342
|
-
var res =
|
|
1343
|
-
ascii: '',
|
|
1344
|
-
ascii_tsv: '',
|
|
1345
|
-
ascii_csv: '',
|
|
1346
|
-
ascii_md: ''
|
|
1347
|
-
};
|
|
1570
|
+
var res = (0, common_1.initAsciiData)();
|
|
1348
1571
|
try {
|
|
1349
1572
|
try {
|
|
1350
1573
|
for (var _b = tslib_1.__values(node.childNodes), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
1351
1574
|
var child = _c.value;
|
|
1352
1575
|
var data = serialize.visitNode(child, '');
|
|
1353
|
-
res = (0, common_1.AddToAsciiData)(res,
|
|
1576
|
+
res = (0, common_1.AddToAsciiData)(res, data);
|
|
1577
|
+
child.currentData = res;
|
|
1354
1578
|
}
|
|
1355
1579
|
}
|
|
1356
1580
|
catch (e_2_1) { e_2 = { error: e_2_1 }; }
|
|
@@ -1360,6 +1584,7 @@ var handleAll = function (node, serialize) {
|
|
|
1360
1584
|
}
|
|
1361
1585
|
finally { if (e_2) throw e_2.error; }
|
|
1362
1586
|
}
|
|
1587
|
+
node.currentData = res;
|
|
1363
1588
|
return res;
|
|
1364
1589
|
}
|
|
1365
1590
|
catch (e) {
|