@syncfusion/ej2-office-common 35.1.37 → 35.1.43
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/ej2-office-common.umd.min.js +2 -2
- package/dist/ej2-office-common.umd.min.js.map +1 -1
- package/dist/es6/ej2-office-common.es2015.js +5421 -6017
- package/dist/es6/ej2-office-common.es2015.js.map +1 -1
- package/dist/es6/ej2-office-common.es5.js +6270 -7203
- package/dist/es6/ej2-office-common.es5.js.map +1 -1
- package/dist/global/ej2-office-common.min.js +2 -2
- package/dist/global/ej2-office-common.min.js.map +1 -1
- package/dist/global/index.d.ts +1 -1
- package/office-common.js +4 -0
- package/package.json +11 -7
- package/src/index.d.ts +3 -17
- package/src/index.js +3 -18
- package/src/office-common/features/index.d.ts +6 -0
- package/src/office-common/features/index.js +6 -0
- package/src/office-common/features/mathml/index.d.ts +25 -0
- package/src/office-common/features/mathml/index.js +22 -0
- package/src/office-common/features/mathml/latex/latex-generator.d.ts +8 -0
- package/src/office-common/features/mathml/latex/latex-generator.js +357 -0
- package/src/office-common/features/mathml/latex/latex-parser.d.ts +87 -0
- package/src/office-common/features/mathml/latex/latex-parser.js +1206 -0
- package/src/office-common/features/mathml/latex/latex-symbols.d.ts +13 -0
- package/src/office-common/features/mathml/latex/latex-symbols.js +681 -0
- package/src/office-common/features/mathml/math-settings.d.ts +54 -0
- package/src/office-common/features/mathml/math-settings.js +174 -0
- package/src/office-common/features/mathml/office-math/adapter.d.ts +59 -0
- package/src/office-common/features/mathml/office-math/adapter.js +6 -0
- package/src/office-common/features/mathml/office-math/basic.d.ts +91 -0
- package/src/office-common/features/mathml/office-math/basic.js +93 -0
- package/src/office-common/features/mathml/office-math/break.d.ts +30 -0
- package/src/office-common/features/mathml/office-math/break.js +75 -0
- package/src/office-common/features/mathml/office-math/collection.d.ts +104 -0
- package/src/office-common/features/mathml/office-math/collection.js +170 -0
- package/src/office-common/features/mathml/office-math/entity.d.ts +12 -0
- package/src/office-common/features/mathml/office-math/entity.js +3 -0
- package/src/office-common/features/mathml/office-math/enums.d.ts +97 -0
- package/src/office-common/features/mathml/office-math/enums.js +108 -0
- package/src/office-common/features/mathml/office-math/format.d.ts +28 -0
- package/src/office-common/features/mathml/office-math/format.js +90 -0
- package/src/office-common/features/mathml/office-math/function-base.d.ts +27 -0
- package/src/office-common/features/mathml/office-math/function-base.js +69 -0
- package/src/office-common/features/mathml/office-math/function-collection.d.ts +29 -0
- package/src/office-common/features/mathml/office-math/function-collection.js +76 -0
- package/src/office-common/features/mathml/office-math/functions-basic.d.ts +118 -0
- package/src/office-common/features/mathml/office-math/functions-basic.js +331 -0
- package/src/office-common/features/mathml/office-math/functions-multi.d.ts +156 -0
- package/src/office-common/features/mathml/office-math/functions-multi.js +407 -0
- package/src/office-common/features/mathml/office-math/index.d.ts +27 -0
- package/src/office-common/features/mathml/office-math/index.js +25 -0
- package/src/office-common/features/mathml/office-math/keys.d.ts +6 -0
- package/src/office-common/features/mathml/office-math/keys.js +20 -0
- package/src/office-common/features/mathml/office-math/math-clone.d.ts +20 -0
- package/src/office-common/features/mathml/office-math/math-clone.js +203 -0
- package/src/office-common/features/mathml/office-math/math-collection.d.ts +19 -0
- package/src/office-common/features/mathml/office-math/math-collection.js +41 -0
- package/src/office-common/features/mathml/office-math/math-equality.d.ts +21 -0
- package/src/office-common/features/mathml/office-math/math-equality.js +115 -0
- package/src/office-common/features/mathml/office-math/math-paragraph.d.ts +58 -0
- package/src/office-common/features/mathml/office-math/math-paragraph.js +126 -0
- package/src/office-common/features/mathml/office-math/math-traversal.d.ts +23 -0
- package/src/office-common/features/mathml/office-math/math-traversal.js +95 -0
- package/src/office-common/features/mathml/office-math/matrix-collections.d.ts +54 -0
- package/src/office-common/features/mathml/office-math/matrix-collections.js +113 -0
- package/src/office-common/features/mathml/office-math/matrix-column.d.ts +43 -0
- package/src/office-common/features/mathml/office-math/matrix-column.js +96 -0
- package/src/office-common/features/mathml/office-math/matrix-row.d.ts +38 -0
- package/src/office-common/features/mathml/office-math/matrix-row.js +71 -0
- package/src/office-common/features/mathml/office-math/matrix.d.ts +62 -0
- package/src/office-common/features/mathml/office-math/matrix.js +158 -0
- package/src/office-common/features/mathml/office-math/office-math.d.ts +55 -0
- package/src/office-common/features/mathml/office-math/office-math.js +116 -0
- package/src/office-common/features/mathml/office-math/owner-holder.d.ts +42 -0
- package/src/office-common/features/mathml/office-math/owner-holder.js +87 -0
- package/src/office-common/features/mathml/office-math/property-store.d.ts +66 -0
- package/src/office-common/features/mathml/office-math/property-store.js +99 -0
- package/src/office-common/features/mathml/office-math/run-element.d.ts +31 -0
- package/src/office-common/features/mathml/office-math/run-element.js +97 -0
- package/src/office-common/features/mathml/office-math/unknown-element.d.ts +37 -0
- package/src/office-common/features/mathml/office-math/unknown-element.js +62 -0
- package/src/office-common/features/mathml/office-math/xml-equal.d.ts +13 -0
- package/src/office-common/features/mathml/office-math/xml-equal.js +24 -0
- package/src/office-common/features/mathml/parse/office-math-parser.d.ts +24 -0
- package/src/office-common/features/mathml/parse/office-math-parser.js +396 -0
- package/src/office-common/features/mathml/parse/office-math-properties.d.ts +165 -0
- package/src/office-common/features/mathml/parse/office-math-properties.js +432 -0
- package/src/office-common/features/mathml/parse/parse-options.d.ts +22 -0
- package/src/office-common/features/mathml/parse/parse-options.js +3 -0
- package/src/office-common/features/mathml/serialize/office-math-properties-writer.d.ts +38 -0
- package/src/office-common/features/mathml/serialize/office-math-properties-writer.js +267 -0
- package/src/office-common/features/mathml/serialize/office-math-serializer.d.ts +23 -0
- package/src/office-common/features/mathml/serialize/office-math-serializer.js +306 -0
- package/src/office-common/features/mathml/serialize/omml-writer.d.ts +123 -0
- package/src/office-common/features/mathml/serialize/omml-writer.js +135 -0
- package/src/office-common/index.d.ts +10 -0
- package/src/office-common/index.js +10 -0
- package/.eslintrc.json +0 -263
- package/.prettierrc.json +0 -5
- package/api-extractor.json +0 -35
- package/core.js +0 -4
- package/encryption.js +0 -4
- package/features.js +0 -4
- package/global.json +0 -6
- package/nuget.config +0 -7
- package/src/all.d.ts +0 -41
- package/src/all.js +0 -38
- package/src/features/index.d.ts +0 -11
- package/src/features/index.js +0 -11
- package/src/features/mathml/index.d.ts +0 -30
- package/src/features/mathml/index.js +0 -22
- package/src/features/mathml/math-factory.d.ts +0 -26
- package/src/features/mathml/math-factory.js +0 -568
- package/src/features/mathml/model/controls.d.ts +0 -896
- package/src/features/mathml/model/controls.js +0 -1541
- package/src/features/mathml/model/math-element.d.ts +0 -173
- package/src/features/mathml/model/math-element.js +0 -315
- package/src/features/mathml/model/roots.d.ts +0 -82
- package/src/features/mathml/model/roots.js +0 -177
- package/src/features/mathml/parse/math-parser.d.ts +0 -43
- package/src/features/mathml/parse/math-parser.js +0 -636
- package/src/features/mathml/serialize/math-serializer.d.ts +0 -34
- package/src/features/mathml/serialize/math-serializer.js +0 -749
- package/tsconfig.build.json +0 -13
- package/tsconfig.harness.json +0 -32
- package/tslint.json +0 -111
- /package/src/{core → office-common/core}/index.d.ts +0 -0
- /package/src/{core → office-common/core}/index.js +0 -0
- /package/src/{core → office-common/core}/xml/index.d.ts +0 -0
- /package/src/{core → office-common/core}/xml/index.js +0 -0
- /package/src/{core → office-common/core}/xml/model.d.ts +0 -0
- /package/src/{core → office-common/core}/xml/model.js +0 -0
- /package/src/{encryption → office-common/encryption}/agile-constants.d.ts +0 -0
- /package/src/{encryption → office-common/encryption}/agile-constants.js +0 -0
- /package/src/{encryption → office-common/encryption}/agile-encryption-info.d.ts +0 -0
- /package/src/{encryption → office-common/encryption}/agile-encryption-info.js +0 -0
- /package/src/{encryption → office-common/encryption}/agile-password.d.ts +0 -0
- /package/src/{encryption → office-common/encryption}/agile-password.js +0 -0
- /package/src/{encryption → office-common/encryption}/cfb-reader.d.ts +0 -0
- /package/src/{encryption → office-common/encryption}/cfb-reader.js +0 -0
- /package/src/{encryption → office-common/encryption}/crypto-primitives.d.ts +0 -0
- /package/src/{encryption → office-common/encryption}/crypto-primitives.js +0 -0
- /package/src/{encryption → office-common/encryption}/decrypt-encrypted-package.d.ts +0 -0
- /package/src/{encryption → office-common/encryption}/decrypt-encrypted-package.js +0 -0
- /package/src/{encryption → office-common/encryption}/encryption-info-xml.d.ts +0 -0
- /package/src/{encryption → office-common/encryption}/encryption-info-xml.js +0 -0
- /package/src/{encryption → office-common/encryption}/errors.d.ts +0 -0
- /package/src/{encryption → office-common/encryption}/errors.js +0 -0
- /package/src/{encryption → office-common/encryption}/index.d.ts +0 -0
- /package/src/{encryption → office-common/encryption}/index.js +0 -0
- /package/src/{features → office-common/features}/diagrams/constants.d.ts +0 -0
- /package/src/{features → office-common/features}/diagrams/constants.js +0 -0
- /package/src/{features → office-common/features}/diagrams/diagram-data-model.d.ts +0 -0
- /package/src/{features → office-common/features}/diagrams/diagram-data-model.js +0 -0
- /package/src/{features → office-common/features}/diagrams/diagram-parsers.d.ts +0 -0
- /package/src/{features → office-common/features}/diagrams/diagram-parsers.js +0 -0
- /package/src/{features → office-common/features}/diagrams/diagram-serializers.d.ts +0 -0
- /package/src/{features → office-common/features}/diagrams/diagram-serializers.js +0 -0
- /package/src/{features → office-common/features}/diagrams/diagram-views.d.ts +0 -0
- /package/src/{features → office-common/features}/diagrams/diagram-views.js +0 -0
- /package/src/{features → office-common/features}/diagrams/element-tree.d.ts +0 -0
- /package/src/{features → office-common/features}/diagrams/element-tree.js +0 -0
- /package/src/{features → office-common/features}/diagrams/errors.d.ts +0 -0
- /package/src/{features → office-common/features}/diagrams/errors.js +0 -0
- /package/src/{features → office-common/features}/diagrams/index.d.ts +0 -0
- /package/src/{features → office-common/features}/diagrams/index.js +0 -0
- /package/src/{features → office-common/features}/diagrams/smart-art-catalog.d.ts +0 -0
- /package/src/{features → office-common/features}/diagrams/smart-art-catalog.js +0 -0
- /package/src/{features → office-common/features}/diagrams/smart-art-diagram.d.ts +0 -0
- /package/src/{features → office-common/features}/diagrams/smart-art-diagram.js +0 -0
- /package/src/{features → office-common/features}/ink/constants.d.ts +0 -0
- /package/src/{features → office-common/features}/ink/constants.js +0 -0
- /package/src/{features → office-common/features}/ink/index.d.ts +0 -0
- /package/src/{features → office-common/features}/ink/index.js +0 -0
- /package/src/{features → office-common/features}/ink/ink-effects.d.ts +0 -0
- /package/src/{features → office-common/features}/ink/ink-effects.js +0 -0
- /package/src/{features → office-common/features}/ink/ink-model.d.ts +0 -0
- /package/src/{features → office-common/features}/ink/ink-model.js +0 -0
- /package/src/{features → office-common/features}/ink/ink-parser.d.ts +0 -0
- /package/src/{features → office-common/features}/ink/ink-parser.js +0 -0
- /package/src/{features → office-common/features}/ink/ink-serializer.d.ts +0 -0
- /package/src/{features → office-common/features}/ink/ink-serializer.js +0 -0
- /package/src/{features → office-common/features}/ink/ink-units.d.ts +0 -0
- /package/src/{features → office-common/features}/ink/ink-units.js +0 -0
- /package/src/{features → office-common/features}/ink/ink-xml.d.ts +0 -0
- /package/src/{features → office-common/features}/ink/ink-xml.js +0 -0
- /package/src/{features → office-common/features}/ink/trace-codec.d.ts +0 -0
- /package/src/{features → office-common/features}/ink/trace-codec.js +0 -0
- /package/src/{features → office-common/features}/mathml/constants.d.ts +0 -0
- /package/src/{features → office-common/features}/mathml/constants.js +0 -0
- /package/src/{features → office-common/features}/mathml/errors.d.ts +0 -0
- /package/src/{features → office-common/features}/mathml/errors.js +0 -0
- /package/src/{features → office-common/features}/mathml/model/enums.d.ts +0 -0
- /package/src/{features → office-common/features}/mathml/model/enums.js +0 -0
- /package/src/{features → office-common/features}/mathml/openxml.d.ts +0 -0
- /package/src/{features → office-common/features}/mathml/openxml.js +0 -0
- /package/src/{features → office-common/features}/smart-art/diagram-xml.d.ts +0 -0
- /package/src/{features → office-common/features}/smart-art/diagram-xml.js +0 -0
- /package/src/{features → office-common/features}/smart-art/errors.d.ts +0 -0
- /package/src/{features → office-common/features}/smart-art/errors.js +0 -0
- /package/src/{features → office-common/features}/smart-art/index.d.ts +0 -0
- /package/src/{features → office-common/features}/smart-art/index.js +0 -0
- /package/src/{features → office-common/features}/smart-art/minimal-samples.d.ts +0 -0
- /package/src/{features → office-common/features}/smart-art/minimal-samples.js +0 -0
- /package/src/{features → office-common/features}/smart-art/mutators.d.ts +0 -0
- /package/src/{features → office-common/features}/smart-art/mutators.js +0 -0
- /package/src/{features → office-common/features}/smart-art/namespaces.d.ts +0 -0
- /package/src/{features → office-common/features}/smart-art/namespaces.js +0 -0
- /package/src/{features → office-common/features}/smart-art/package-graph.d.ts +0 -0
- /package/src/{features → office-common/features}/smart-art/package-graph.js +0 -0
- /package/src/{features → office-common/features}/smart-art/parse-colors.d.ts +0 -0
- /package/src/{features → office-common/features}/smart-art/parse-colors.js +0 -0
- /package/src/{features → office-common/features}/smart-art/parse-data.d.ts +0 -0
- /package/src/{features → office-common/features}/smart-art/parse-data.js +0 -0
- /package/src/{features → office-common/features}/smart-art/parse-layout.d.ts +0 -0
- /package/src/{features → office-common/features}/smart-art/parse-layout.js +0 -0
- /package/src/{features → office-common/features}/smart-art/parse-rel-ids.d.ts +0 -0
- /package/src/{features → office-common/features}/smart-art/parse-rel-ids.js +0 -0
- /package/src/{features → office-common/features}/smart-art/parse-style.d.ts +0 -0
- /package/src/{features → office-common/features}/smart-art/parse-style.js +0 -0
- /package/src/{features → office-common/features}/smart-art/point-text.d.ts +0 -0
- /package/src/{features → office-common/features}/smart-art/point-text.js +0 -0
- /package/src/{features → office-common/features}/smart-art/register.d.ts +0 -0
- /package/src/{features → office-common/features}/smart-art/register.js +0 -0
- /package/src/{features → office-common/features}/smart-art/serialize.d.ts +0 -0
- /package/src/{features → office-common/features}/smart-art/serialize.js +0 -0
- /package/src/{features → office-common/features}/smart-art/types.d.ts +0 -0
- /package/src/{features → office-common/features}/smart-art/types.js +0 -0
|
@@ -1,749 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Strict typed Math* DOM → OMML OpenXml element-tree serializer.
|
|
3
|
-
*
|
|
4
|
-
* Source: mathml-spec §9; ECMA-376-4 Annex A.8.1.
|
|
5
|
-
* Throws {@link MathmlValidationError} on schema violations (typed path).
|
|
6
|
-
* Preserve-only / unknown nodes re-emit `preservedXml` verbatim.
|
|
7
|
-
*/
|
|
8
|
-
var __values = (this && this.__values) || function (o) {
|
|
9
|
-
var m = typeof Symbol === "function" && o[Symbol.iterator], i = 0;
|
|
10
|
-
if (m) return m.call(o);
|
|
11
|
-
return {
|
|
12
|
-
next: function () {
|
|
13
|
-
if (o && i >= o.length) o = void 0;
|
|
14
|
-
return { value: o && o[i++], done: !o };
|
|
15
|
-
}
|
|
16
|
-
};
|
|
17
|
-
};
|
|
18
|
-
var __read = (this && this.__read) || function (o, n) {
|
|
19
|
-
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
20
|
-
if (!m) return o;
|
|
21
|
-
var i = m.call(o), r, ar = [], e;
|
|
22
|
-
try {
|
|
23
|
-
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
|
24
|
-
}
|
|
25
|
-
catch (error) { e = { error: error }; }
|
|
26
|
-
finally {
|
|
27
|
-
try {
|
|
28
|
-
if (r && !r.done && (m = i["return"])) m.call(i);
|
|
29
|
-
}
|
|
30
|
-
finally { if (e) throw e.error; }
|
|
31
|
-
}
|
|
32
|
-
return ar;
|
|
33
|
-
};
|
|
34
|
-
import { MATH_NAMESPACE, MATH_PREFIX_FALLBACKS, XML_NAMESPACE } from '../constants';
|
|
35
|
-
import { MathmlValidationError } from '../errors';
|
|
36
|
-
import { createElement, createText } from '../openxml';
|
|
37
|
-
import { MATH_FTYPE_VALUES, MATH_JC_VALUES, MATH_LIMLOC_VALUES, MATH_SCRIPT_VALUES, MATH_SHP_VALUES, MATH_STYLE_VALUES, MATH_TOPBOT_VALUES, isInteger2, isInteger255 } from '../model/enums';
|
|
38
|
-
import { UnknownMathElement } from '../model/math-element';
|
|
39
|
-
function resolvePrefix(options) {
|
|
40
|
-
var e_1, _a;
|
|
41
|
-
if ((options == null ? void 0 : options.prefix) !== undefined && options.prefix.length > 0) {
|
|
42
|
-
return options.prefix;
|
|
43
|
-
}
|
|
44
|
-
var reserved = new Set(function () {
|
|
45
|
-
var _nc = options == null ? void 0 : options.reservedPrefixes;
|
|
46
|
-
return _nc != null ? _nc : [];
|
|
47
|
-
}());
|
|
48
|
-
try {
|
|
49
|
-
for (var MATH_PREFIX_FALLBACKS_1 = __values(MATH_PREFIX_FALLBACKS), MATH_PREFIX_FALLBACKS_1_1 = MATH_PREFIX_FALLBACKS_1.next(); !MATH_PREFIX_FALLBACKS_1_1.done; MATH_PREFIX_FALLBACKS_1_1 = MATH_PREFIX_FALLBACKS_1.next()) {
|
|
50
|
-
var candidate = MATH_PREFIX_FALLBACKS_1_1.value;
|
|
51
|
-
if (!reserved.has(candidate)) {
|
|
52
|
-
return candidate;
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
57
|
-
finally {
|
|
58
|
-
try {
|
|
59
|
-
if (MATH_PREFIX_FALLBACKS_1_1 && !MATH_PREFIX_FALLBACKS_1_1.done && (_a = MATH_PREFIX_FALLBACKS_1.return)) _a.call(MATH_PREFIX_FALLBACKS_1);
|
|
60
|
-
}
|
|
61
|
-
finally { if (e_1) throw e_1.error; }
|
|
62
|
-
}
|
|
63
|
-
return 'm999';
|
|
64
|
-
}
|
|
65
|
-
function needsXmlSpacePreserve(value) {
|
|
66
|
-
if (value.length === 0) {
|
|
67
|
-
return true;
|
|
68
|
-
}
|
|
69
|
-
var first = value[0];
|
|
70
|
-
var last = value[value.length - 1];
|
|
71
|
-
return first === ' ' || first === '\t' || first === '\n' || first === '\r' || last === ' ' || last === '\t' || last === '\n' || last === '\r';
|
|
72
|
-
}
|
|
73
|
-
function emitOnOff(value) {
|
|
74
|
-
// ECMA-376 OnOffType — prefer canonical '1' / '0'.
|
|
75
|
-
return value ? '1' : '0';
|
|
76
|
-
}
|
|
77
|
-
function mEl(ctx, localName, children, attributes) {
|
|
78
|
-
if (children === void 0) { children = []; }
|
|
79
|
-
if (attributes === void 0) { attributes = []; }
|
|
80
|
-
return createElement(MATH_NAMESPACE, localName, ctx.prefix, {
|
|
81
|
-
attributes: attributes,
|
|
82
|
-
children: children
|
|
83
|
-
});
|
|
84
|
-
}
|
|
85
|
-
function valAttr(value) {
|
|
86
|
-
return {
|
|
87
|
-
namespaceUri: '',
|
|
88
|
-
localName: 'val',
|
|
89
|
-
prefix: '',
|
|
90
|
-
value: value
|
|
91
|
-
};
|
|
92
|
-
}
|
|
93
|
-
function valEl(ctx, localName, value) {
|
|
94
|
-
return mEl(ctx, localName, [], [valAttr(value)]);
|
|
95
|
-
}
|
|
96
|
-
function onOffEl(ctx, localName, value) {
|
|
97
|
-
return mEl(ctx, localName, [], [valAttr(emitOnOff(value))]);
|
|
98
|
-
}
|
|
99
|
-
function pushCtrlPr(children, ctrlPr) {
|
|
100
|
-
if (ctrlPr !== undefined) {
|
|
101
|
-
children.push(ctrlPr);
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
function assertInUnion(value, allowed, path, label) {
|
|
105
|
-
if (!(allowed.indexOf(value) !== -1)) {
|
|
106
|
-
throw new MathmlValidationError("Illegal " + label + " token '" + value + "' (not in schema enum)", path, 'enum-value');
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
/**
|
|
110
|
-
* Serialize a MathArgument as a named CT_OMathArg element
|
|
111
|
-
* (`e` | `num` | `den` | `sub` | `sup` | `lim` | `deg` | `fName`).
|
|
112
|
-
*/
|
|
113
|
-
function emitArg(ctx, localName, arg) {
|
|
114
|
-
var childPath = ctx.path + "." + localName;
|
|
115
|
-
var kids = [];
|
|
116
|
-
var argSz = arg.properties.argSz;
|
|
117
|
-
if (argSz !== undefined) {
|
|
118
|
-
if (!isInteger2(argSz)) {
|
|
119
|
-
throw new MathmlValidationError("argSz must be an integer in \u22122..2 (ST_Integer2), got " + String(argSz), childPath + ".argPr.argSz", 'value-range');
|
|
120
|
-
}
|
|
121
|
-
kids.push(mEl(ctx, 'argPr', [valEl(ctx, 'argSz', String(argSz))]));
|
|
122
|
-
}
|
|
123
|
-
for (var i = 0; i < arg.item.length; i++) {
|
|
124
|
-
var child = arg.item[i];
|
|
125
|
-
if (child === undefined) {
|
|
126
|
-
continue;
|
|
127
|
-
}
|
|
128
|
-
kids.push(serializeNode(child, {
|
|
129
|
-
prefix: ctx.prefix,
|
|
130
|
-
path: childPath + "[" + String(i) + "]"
|
|
131
|
-
}));
|
|
132
|
-
}
|
|
133
|
-
pushCtrlPr(kids, arg.ctrlPr);
|
|
134
|
-
return mEl(ctx, localName, kids);
|
|
135
|
-
}
|
|
136
|
-
function emitText(ctx, node) {
|
|
137
|
-
var attrs = [];
|
|
138
|
-
var space = node.xmlSpace;
|
|
139
|
-
if (space === undefined && needsXmlSpacePreserve(node.value)) {
|
|
140
|
-
space = 'preserve';
|
|
141
|
-
}
|
|
142
|
-
if (space !== undefined) {
|
|
143
|
-
attrs.push({
|
|
144
|
-
namespaceUri: XML_NAMESPACE,
|
|
145
|
-
localName: 'space',
|
|
146
|
-
prefix: 'xml',
|
|
147
|
-
value: space
|
|
148
|
-
});
|
|
149
|
-
}
|
|
150
|
-
return mEl(ctx, 't', [createText(node.value)], attrs);
|
|
151
|
-
}
|
|
152
|
-
function emitRunPr(ctx, run) {
|
|
153
|
-
var p = run.properties;
|
|
154
|
-
var kids = [];
|
|
155
|
-
if (p.isLiteral !== undefined) {
|
|
156
|
-
kids.push(onOffEl(ctx, 'lit', p.isLiteral));
|
|
157
|
-
}
|
|
158
|
-
if (p.isNormal !== undefined) {
|
|
159
|
-
kids.push(onOffEl(ctx, 'nor', p.isNormal));
|
|
160
|
-
}
|
|
161
|
-
if (p.scr !== undefined) {
|
|
162
|
-
assertInUnion(p.scr, MATH_SCRIPT_VALUES, ctx.path + ".rPr.scr", 'ST_Script');
|
|
163
|
-
kids.push(valEl(ctx, 'scr', p.scr));
|
|
164
|
-
}
|
|
165
|
-
if (p.sty !== undefined) {
|
|
166
|
-
assertInUnion(p.sty, MATH_STYLE_VALUES, ctx.path + ".rPr.sty", 'ST_Style');
|
|
167
|
-
kids.push(valEl(ctx, 'sty', p.sty));
|
|
168
|
-
}
|
|
169
|
-
if (p.brk !== undefined) {
|
|
170
|
-
if (!isInteger255(p.brk) && !(Number.isInteger(p.brk) && p.brk === 0)) {
|
|
171
|
-
// ST_Integer255 is 1..255; allow 0 as present break index edge (Word).
|
|
172
|
-
if (!Number.isInteger(p.brk) || p.brk < 0 || p.brk > 255) {
|
|
173
|
-
throw new MathmlValidationError("brk must be an integer in 0..255, got " + String(p.brk), ctx.path + ".rPr.brk", 'value-range');
|
|
174
|
-
}
|
|
175
|
-
}
|
|
176
|
-
kids.push(valEl(ctx, 'brk', String(p.brk)));
|
|
177
|
-
}
|
|
178
|
-
if (p.isAligned !== undefined) {
|
|
179
|
-
kids.push(onOffEl(ctx, 'aln', p.isAligned));
|
|
180
|
-
}
|
|
181
|
-
if (kids.length === 0) {
|
|
182
|
-
return undefined;
|
|
183
|
-
}
|
|
184
|
-
return mEl(ctx, 'rPr', kids);
|
|
185
|
-
}
|
|
186
|
-
function emitRun(ctx, run) {
|
|
187
|
-
var e_2, _a;
|
|
188
|
-
var kids = [];
|
|
189
|
-
var rPr = emitRunPr(ctx, run);
|
|
190
|
-
if (rPr !== undefined) {
|
|
191
|
-
kids.push(rPr);
|
|
192
|
-
}
|
|
193
|
-
if (run.wRPr !== undefined) {
|
|
194
|
-
kids.push(run.wRPr);
|
|
195
|
-
}
|
|
196
|
-
for (var i = 0; i < run.children.length; i++) {
|
|
197
|
-
var child = run.children[i];
|
|
198
|
-
if (child === undefined) {
|
|
199
|
-
continue;
|
|
200
|
-
}
|
|
201
|
-
kids.push(serializeNode(child, {
|
|
202
|
-
prefix: ctx.prefix,
|
|
203
|
-
path: ctx.path + ".r[" + String(i) + "]"
|
|
204
|
-
}));
|
|
205
|
-
}
|
|
206
|
-
try {
|
|
207
|
-
for (var _b = __values(run.opaqueChildren), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
208
|
-
var opaque = _c.value;
|
|
209
|
-
kids.push(opaque);
|
|
210
|
-
}
|
|
211
|
-
}
|
|
212
|
-
catch (e_2_1) { e_2 = { error: e_2_1 }; }
|
|
213
|
-
finally {
|
|
214
|
-
try {
|
|
215
|
-
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
216
|
-
}
|
|
217
|
-
finally { if (e_2) throw e_2.error; }
|
|
218
|
-
}
|
|
219
|
-
return mEl(ctx, 'r', kids);
|
|
220
|
-
}
|
|
221
|
-
function emitAccent(ctx, node) {
|
|
222
|
-
var kids = [];
|
|
223
|
-
var prKids = [];
|
|
224
|
-
if (node.properties.chr !== undefined) {
|
|
225
|
-
prKids.push(valEl(ctx, 'chr', node.properties.chr));
|
|
226
|
-
}
|
|
227
|
-
pushCtrlPr(prKids, node.properties.ctrlPr);
|
|
228
|
-
if (prKids.length > 0) {
|
|
229
|
-
kids.push(mEl(ctx, 'accPr', prKids));
|
|
230
|
-
}
|
|
231
|
-
kids.push(emitArg(ctx, 'e', node.base));
|
|
232
|
-
return mEl(ctx, 'acc', kids);
|
|
233
|
-
}
|
|
234
|
-
function emitBar(ctx, node) {
|
|
235
|
-
var kids = [];
|
|
236
|
-
var prKids = [];
|
|
237
|
-
if (node.properties.pos !== undefined) {
|
|
238
|
-
assertInUnion(node.properties.pos, MATH_TOPBOT_VALUES, ctx.path + ".barPr.pos", 'ST_TopBot');
|
|
239
|
-
prKids.push(valEl(ctx, 'pos', node.properties.pos));
|
|
240
|
-
}
|
|
241
|
-
pushCtrlPr(prKids, node.properties.ctrlPr);
|
|
242
|
-
if (prKids.length > 0) {
|
|
243
|
-
kids.push(mEl(ctx, 'barPr', prKids));
|
|
244
|
-
}
|
|
245
|
-
kids.push(emitArg(ctx, 'e', node.base));
|
|
246
|
-
return mEl(ctx, 'bar', kids);
|
|
247
|
-
}
|
|
248
|
-
function emitBox(ctx, node) {
|
|
249
|
-
var kids = [];
|
|
250
|
-
var prKids = [];
|
|
251
|
-
var p = node.properties;
|
|
252
|
-
if (p.isOperatorEmulated !== undefined) {
|
|
253
|
-
prKids.push(onOffEl(ctx, 'opEmu', p.isOperatorEmulated));
|
|
254
|
-
}
|
|
255
|
-
if (p.isNoBreak !== undefined) {
|
|
256
|
-
prKids.push(onOffEl(ctx, 'noBreak', p.isNoBreak));
|
|
257
|
-
}
|
|
258
|
-
if (p.isDifferential !== undefined) {
|
|
259
|
-
prKids.push(onOffEl(ctx, 'diff', p.isDifferential));
|
|
260
|
-
}
|
|
261
|
-
if (p.isAligned !== undefined) {
|
|
262
|
-
prKids.push(onOffEl(ctx, 'aln', p.isAligned));
|
|
263
|
-
}
|
|
264
|
-
pushCtrlPr(prKids, p.ctrlPr);
|
|
265
|
-
if (prKids.length > 0) {
|
|
266
|
-
kids.push(mEl(ctx, 'boxPr', prKids));
|
|
267
|
-
}
|
|
268
|
-
kids.push(emitArg(ctx, 'e', node.base));
|
|
269
|
-
return mEl(ctx, 'box', kids);
|
|
270
|
-
}
|
|
271
|
-
/** Public API boolean → OMML OnOff local name for `m:borderBoxPr`. */
|
|
272
|
-
var BORDER_BOX_ONOFF_EMIT = [['isTopHidden', 'hideTop'], ['isBottomHidden', 'hideBot'], ['isLeftHidden', 'hideLeft'], ['isRightHidden', 'hideRight'], ['hasHorizontalStrike', 'strikeH'], ['hasVerticalStrike', 'strikeV'], ['hasBottomLeftToTopRightStrike', 'strikeBLTR'], ['hasTopLeftToBottomRightStrike', 'strikeTLBR']];
|
|
273
|
-
function emitBorderBox(ctx, node) {
|
|
274
|
-
var e_3, _a;
|
|
275
|
-
var kids = [];
|
|
276
|
-
var prKids = [];
|
|
277
|
-
var p = node.properties;
|
|
278
|
-
try {
|
|
279
|
-
for (var BORDER_BOX_ONOFF_EMIT_1 = __values(BORDER_BOX_ONOFF_EMIT), BORDER_BOX_ONOFF_EMIT_1_1 = BORDER_BOX_ONOFF_EMIT_1.next(); !BORDER_BOX_ONOFF_EMIT_1_1.done; BORDER_BOX_ONOFF_EMIT_1_1 = BORDER_BOX_ONOFF_EMIT_1.next()) {
|
|
280
|
-
var _b = __read(BORDER_BOX_ONOFF_EMIT_1_1.value, 2), apiName = _b[0], xmlName = _b[1];
|
|
281
|
-
var v = p[apiName];
|
|
282
|
-
if (typeof v === 'boolean') {
|
|
283
|
-
prKids.push(onOffEl(ctx, xmlName, v));
|
|
284
|
-
}
|
|
285
|
-
}
|
|
286
|
-
}
|
|
287
|
-
catch (e_3_1) { e_3 = { error: e_3_1 }; }
|
|
288
|
-
finally {
|
|
289
|
-
try {
|
|
290
|
-
if (BORDER_BOX_ONOFF_EMIT_1_1 && !BORDER_BOX_ONOFF_EMIT_1_1.done && (_a = BORDER_BOX_ONOFF_EMIT_1.return)) _a.call(BORDER_BOX_ONOFF_EMIT_1);
|
|
291
|
-
}
|
|
292
|
-
finally { if (e_3) throw e_3.error; }
|
|
293
|
-
}
|
|
294
|
-
pushCtrlPr(prKids, p.ctrlPr);
|
|
295
|
-
if (prKids.length > 0) {
|
|
296
|
-
kids.push(mEl(ctx, 'borderBoxPr', prKids));
|
|
297
|
-
}
|
|
298
|
-
kids.push(emitArg(ctx, 'e', node.base));
|
|
299
|
-
return mEl(ctx, 'borderBox', kids);
|
|
300
|
-
}
|
|
301
|
-
function emitDelimiter(ctx, node) {
|
|
302
|
-
var e_4, _a;
|
|
303
|
-
node.assertSerializable(ctx.path);
|
|
304
|
-
var kids = [];
|
|
305
|
-
var prKids = [];
|
|
306
|
-
var p = node.properties;
|
|
307
|
-
if (p.begChr !== undefined) {
|
|
308
|
-
prKids.push(valEl(ctx, 'begChr', p.begChr));
|
|
309
|
-
}
|
|
310
|
-
if (p.sepChr !== undefined) {
|
|
311
|
-
prKids.push(valEl(ctx, 'sepChr', p.sepChr));
|
|
312
|
-
}
|
|
313
|
-
if (p.endChr !== undefined) {
|
|
314
|
-
prKids.push(valEl(ctx, 'endChr', p.endChr));
|
|
315
|
-
}
|
|
316
|
-
if (p.canGrow !== undefined) {
|
|
317
|
-
prKids.push(onOffEl(ctx, 'grow', p.canGrow));
|
|
318
|
-
}
|
|
319
|
-
if (p.shp !== undefined) {
|
|
320
|
-
assertInUnion(p.shp, MATH_SHP_VALUES, ctx.path + ".dPr.shp", 'ST_Shp');
|
|
321
|
-
prKids.push(valEl(ctx, 'shp', p.shp));
|
|
322
|
-
}
|
|
323
|
-
pushCtrlPr(prKids, p.ctrlPr);
|
|
324
|
-
if (prKids.length > 0) {
|
|
325
|
-
kids.push(mEl(ctx, 'dPr', prKids));
|
|
326
|
-
}
|
|
327
|
-
try {
|
|
328
|
-
for (var _b = __values(node.elements), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
329
|
-
var el = _c.value;
|
|
330
|
-
kids.push(emitArg(ctx, 'e', el));
|
|
331
|
-
}
|
|
332
|
-
}
|
|
333
|
-
catch (e_4_1) { e_4 = { error: e_4_1 }; }
|
|
334
|
-
finally {
|
|
335
|
-
try {
|
|
336
|
-
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
337
|
-
}
|
|
338
|
-
finally { if (e_4) throw e_4.error; }
|
|
339
|
-
}
|
|
340
|
-
return mEl(ctx, 'd', kids);
|
|
341
|
-
}
|
|
342
|
-
function emitEqArr(ctx, node) {
|
|
343
|
-
var e_5, _a;
|
|
344
|
-
node.assertSerializable(ctx.path);
|
|
345
|
-
var kids = [];
|
|
346
|
-
var prKids = [];
|
|
347
|
-
var p = node.properties;
|
|
348
|
-
if (p.baseJc !== undefined) {
|
|
349
|
-
prKids.push(valEl(ctx, 'baseJc', p.baseJc));
|
|
350
|
-
}
|
|
351
|
-
if (p.hasMaxDistance !== undefined) {
|
|
352
|
-
prKids.push(onOffEl(ctx, 'maxDist', p.hasMaxDistance));
|
|
353
|
-
}
|
|
354
|
-
if (p.hasObjectDistance !== undefined) {
|
|
355
|
-
prKids.push(onOffEl(ctx, 'objDist', p.hasObjectDistance));
|
|
356
|
-
}
|
|
357
|
-
pushCtrlPr(prKids, p.ctrlPr);
|
|
358
|
-
if (prKids.length > 0) {
|
|
359
|
-
kids.push(mEl(ctx, 'eqArrPr', prKids));
|
|
360
|
-
}
|
|
361
|
-
try {
|
|
362
|
-
for (var _b = __values(node.elements), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
363
|
-
var el = _c.value;
|
|
364
|
-
kids.push(emitArg(ctx, 'e', el));
|
|
365
|
-
}
|
|
366
|
-
}
|
|
367
|
-
catch (e_5_1) { e_5 = { error: e_5_1 }; }
|
|
368
|
-
finally {
|
|
369
|
-
try {
|
|
370
|
-
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
371
|
-
}
|
|
372
|
-
finally { if (e_5) throw e_5.error; }
|
|
373
|
-
}
|
|
374
|
-
return mEl(ctx, 'eqArr', kids);
|
|
375
|
-
}
|
|
376
|
-
function emitFraction(ctx, node) {
|
|
377
|
-
var kids = [];
|
|
378
|
-
var prKids = [];
|
|
379
|
-
if (node.properties.type !== undefined) {
|
|
380
|
-
assertInUnion(node.properties.type, MATH_FTYPE_VALUES, ctx.path + ".fPr.type", 'ST_FType');
|
|
381
|
-
prKids.push(valEl(ctx, 'type', node.properties.type));
|
|
382
|
-
}
|
|
383
|
-
pushCtrlPr(prKids, node.properties.ctrlPr);
|
|
384
|
-
if (prKids.length > 0) {
|
|
385
|
-
kids.push(mEl(ctx, 'fPr', prKids));
|
|
386
|
-
}
|
|
387
|
-
// CT_F order: fPr?, num, den (OMML local names unchanged)
|
|
388
|
-
kids.push(emitArg(ctx, 'num', node.numerator));
|
|
389
|
-
kids.push(emitArg(ctx, 'den', node.denominator));
|
|
390
|
-
return mEl(ctx, 'f', kids);
|
|
391
|
-
}
|
|
392
|
-
function emitFunction(ctx, node) {
|
|
393
|
-
var kids = [];
|
|
394
|
-
var prKids = [];
|
|
395
|
-
pushCtrlPr(prKids, node.properties.ctrlPr);
|
|
396
|
-
if (prKids.length > 0) {
|
|
397
|
-
kids.push(mEl(ctx, 'funcPr', prKids));
|
|
398
|
-
}
|
|
399
|
-
// CT_Func: funcPr?, fName, e (OMML local name fName unchanged)
|
|
400
|
-
kids.push(emitArg(ctx, 'fName', node.name));
|
|
401
|
-
kids.push(emitArg(ctx, 'e', node.base));
|
|
402
|
-
return mEl(ctx, 'func', kids);
|
|
403
|
-
}
|
|
404
|
-
function emitGroupChr(ctx, node) {
|
|
405
|
-
var kids = [];
|
|
406
|
-
var prKids = [];
|
|
407
|
-
var p = node.properties;
|
|
408
|
-
if (p.chr !== undefined) {
|
|
409
|
-
prKids.push(valEl(ctx, 'chr', p.chr));
|
|
410
|
-
}
|
|
411
|
-
if (p.pos !== undefined) {
|
|
412
|
-
assertInUnion(p.pos, MATH_TOPBOT_VALUES, ctx.path + ".groupChrPr.pos", 'ST_TopBot');
|
|
413
|
-
prKids.push(valEl(ctx, 'pos', p.pos));
|
|
414
|
-
}
|
|
415
|
-
if (p.vertJc !== undefined) {
|
|
416
|
-
assertInUnion(p.vertJc, MATH_TOPBOT_VALUES, ctx.path + ".groupChrPr.vertJc", 'ST_TopBot');
|
|
417
|
-
prKids.push(valEl(ctx, 'vertJc', p.vertJc));
|
|
418
|
-
}
|
|
419
|
-
pushCtrlPr(prKids, p.ctrlPr);
|
|
420
|
-
if (prKids.length > 0) {
|
|
421
|
-
kids.push(mEl(ctx, 'groupChrPr', prKids));
|
|
422
|
-
}
|
|
423
|
-
kids.push(emitArg(ctx, 'e', node.base));
|
|
424
|
-
return mEl(ctx, 'groupChr', kids);
|
|
425
|
-
}
|
|
426
|
-
function emitLimLow(ctx, node) {
|
|
427
|
-
var kids = [];
|
|
428
|
-
var prKids = [];
|
|
429
|
-
pushCtrlPr(prKids, node.properties.ctrlPr);
|
|
430
|
-
if (prKids.length > 0) {
|
|
431
|
-
kids.push(mEl(ctx, 'limLowPr', prKids));
|
|
432
|
-
}
|
|
433
|
-
// CT_LimLow: limLowPr?, e, lim
|
|
434
|
-
kids.push(emitArg(ctx, 'e', node.base));
|
|
435
|
-
kids.push(emitArg(ctx, 'lim', node.lim));
|
|
436
|
-
return mEl(ctx, 'limLow', kids);
|
|
437
|
-
}
|
|
438
|
-
function emitLimUpp(ctx, node) {
|
|
439
|
-
var kids = [];
|
|
440
|
-
var prKids = [];
|
|
441
|
-
pushCtrlPr(prKids, node.properties.ctrlPr);
|
|
442
|
-
if (prKids.length > 0) {
|
|
443
|
-
kids.push(mEl(ctx, 'limUppPr', prKids));
|
|
444
|
-
}
|
|
445
|
-
// CT_LimUpp: limUppPr?, e, lim
|
|
446
|
-
kids.push(emitArg(ctx, 'e', node.base));
|
|
447
|
-
kids.push(emitArg(ctx, 'lim', node.lim));
|
|
448
|
-
return mEl(ctx, 'limUpp', kids);
|
|
449
|
-
}
|
|
450
|
-
function emitMatrixRow(ctx, node) {
|
|
451
|
-
var e_6, _a;
|
|
452
|
-
node.assertSerializable(ctx.path);
|
|
453
|
-
var kids = [];
|
|
454
|
-
try {
|
|
455
|
-
for (var _b = __values(node.elements), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
456
|
-
var el = _c.value;
|
|
457
|
-
kids.push(emitArg(ctx, 'e', el));
|
|
458
|
-
}
|
|
459
|
-
}
|
|
460
|
-
catch (e_6_1) { e_6 = { error: e_6_1 }; }
|
|
461
|
-
finally {
|
|
462
|
-
try {
|
|
463
|
-
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
464
|
-
}
|
|
465
|
-
finally { if (e_6) throw e_6.error; }
|
|
466
|
-
}
|
|
467
|
-
return mEl(ctx, 'mr', kids);
|
|
468
|
-
}
|
|
469
|
-
function emitMatrix(ctx, node) {
|
|
470
|
-
node.assertSerializable(ctx.path);
|
|
471
|
-
var kids = [];
|
|
472
|
-
var prKids = [];
|
|
473
|
-
var p = node.properties;
|
|
474
|
-
if (p.baseJc !== undefined) {
|
|
475
|
-
prKids.push(valEl(ctx, 'baseJc', p.baseJc));
|
|
476
|
-
}
|
|
477
|
-
if (p.isPlaceholderHidden !== undefined) {
|
|
478
|
-
prKids.push(onOffEl(ctx, 'plcHide', p.isPlaceholderHidden));
|
|
479
|
-
}
|
|
480
|
-
pushCtrlPr(prKids, p.ctrlPr);
|
|
481
|
-
if (prKids.length > 0) {
|
|
482
|
-
kids.push(mEl(ctx, 'mPr', prKids));
|
|
483
|
-
}
|
|
484
|
-
for (var i = 0; i < node.rows.length; i++) {
|
|
485
|
-
var row = node.rows[i];
|
|
486
|
-
if (row === undefined) {
|
|
487
|
-
continue;
|
|
488
|
-
}
|
|
489
|
-
kids.push(emitMatrixRow({
|
|
490
|
-
prefix: ctx.prefix,
|
|
491
|
-
path: ctx.path + ".mr[" + String(i) + "]"
|
|
492
|
-
}, row));
|
|
493
|
-
}
|
|
494
|
-
return mEl(ctx, 'm', kids);
|
|
495
|
-
}
|
|
496
|
-
function emitNary(ctx, node) {
|
|
497
|
-
var kids = [];
|
|
498
|
-
var prKids = [];
|
|
499
|
-
var p = node.properties;
|
|
500
|
-
if (p.chr !== undefined) {
|
|
501
|
-
prKids.push(valEl(ctx, 'chr', p.chr));
|
|
502
|
-
}
|
|
503
|
-
if (p.limLoc !== undefined) {
|
|
504
|
-
assertInUnion(p.limLoc, MATH_LIMLOC_VALUES, ctx.path + ".naryPr.limLoc", 'ST_LimLoc');
|
|
505
|
-
prKids.push(valEl(ctx, 'limLoc', p.limLoc));
|
|
506
|
-
}
|
|
507
|
-
if (p.canGrow !== undefined) {
|
|
508
|
-
prKids.push(onOffEl(ctx, 'grow', p.canGrow));
|
|
509
|
-
}
|
|
510
|
-
if (p.isSubscriptHidden !== undefined) {
|
|
511
|
-
prKids.push(onOffEl(ctx, 'subHide', p.isSubscriptHidden));
|
|
512
|
-
}
|
|
513
|
-
if (p.isSuperscriptHidden !== undefined) {
|
|
514
|
-
prKids.push(onOffEl(ctx, 'supHide', p.isSuperscriptHidden));
|
|
515
|
-
}
|
|
516
|
-
pushCtrlPr(prKids, p.ctrlPr);
|
|
517
|
-
if (prKids.length > 0) {
|
|
518
|
-
kids.push(mEl(ctx, 'naryPr', prKids));
|
|
519
|
-
}
|
|
520
|
-
// CT_Nary order: naryPr?, sub, sup, e
|
|
521
|
-
kids.push(emitArg(ctx, 'sub', node.subscript));
|
|
522
|
-
kids.push(emitArg(ctx, 'sup', node.superscript));
|
|
523
|
-
kids.push(emitArg(ctx, 'e', node.base));
|
|
524
|
-
return mEl(ctx, 'nary', kids);
|
|
525
|
-
}
|
|
526
|
-
function emitPhant(ctx, node) {
|
|
527
|
-
var kids = [];
|
|
528
|
-
var prKids = [];
|
|
529
|
-
var p = node.properties;
|
|
530
|
-
if (p.isShown !== undefined) {
|
|
531
|
-
prKids.push(onOffEl(ctx, 'show', p.isShown));
|
|
532
|
-
}
|
|
533
|
-
if (p.isZeroWidth !== undefined) {
|
|
534
|
-
prKids.push(onOffEl(ctx, 'zeroWid', p.isZeroWidth));
|
|
535
|
-
}
|
|
536
|
-
if (p.isZeroAscender !== undefined) {
|
|
537
|
-
prKids.push(onOffEl(ctx, 'zeroAsc', p.isZeroAscender));
|
|
538
|
-
}
|
|
539
|
-
if (p.isZeroDescender !== undefined) {
|
|
540
|
-
prKids.push(onOffEl(ctx, 'zeroDesc', p.isZeroDescender));
|
|
541
|
-
}
|
|
542
|
-
if (p.isTransparent !== undefined) {
|
|
543
|
-
prKids.push(onOffEl(ctx, 'transp', p.isTransparent));
|
|
544
|
-
}
|
|
545
|
-
pushCtrlPr(prKids, p.ctrlPr);
|
|
546
|
-
if (prKids.length > 0) {
|
|
547
|
-
kids.push(mEl(ctx, 'phantPr', prKids));
|
|
548
|
-
}
|
|
549
|
-
kids.push(emitArg(ctx, 'e', node.base));
|
|
550
|
-
return mEl(ctx, 'phant', kids);
|
|
551
|
-
}
|
|
552
|
-
function emitRad(ctx, node) {
|
|
553
|
-
var kids = [];
|
|
554
|
-
var prKids = [];
|
|
555
|
-
if (node.properties.isDegreeHidden !== undefined) {
|
|
556
|
-
prKids.push(onOffEl(ctx, 'degHide', node.properties.isDegreeHidden));
|
|
557
|
-
}
|
|
558
|
-
pushCtrlPr(prKids, node.properties.ctrlPr);
|
|
559
|
-
if (prKids.length > 0) {
|
|
560
|
-
kids.push(mEl(ctx, 'radPr', prKids));
|
|
561
|
-
}
|
|
562
|
-
// CT_Rad: radPr?, deg, e
|
|
563
|
-
kids.push(emitArg(ctx, 'deg', node.deg));
|
|
564
|
-
kids.push(emitArg(ctx, 'e', node.base));
|
|
565
|
-
return mEl(ctx, 'rad', kids);
|
|
566
|
-
}
|
|
567
|
-
function emitScriptPr(ctx, prName, isScriptAligned, ctrlPr) {
|
|
568
|
-
var prKids = [];
|
|
569
|
-
if (isScriptAligned !== undefined) {
|
|
570
|
-
prKids.push(onOffEl(ctx, 'alnScr', isScriptAligned));
|
|
571
|
-
}
|
|
572
|
-
pushCtrlPr(prKids, ctrlPr);
|
|
573
|
-
if (prKids.length === 0) {
|
|
574
|
-
return undefined;
|
|
575
|
-
}
|
|
576
|
-
return mEl(ctx, prName, prKids);
|
|
577
|
-
}
|
|
578
|
-
function emitSPre(ctx, node) {
|
|
579
|
-
var kids = [];
|
|
580
|
-
var pr = emitScriptPr(ctx, 'sPrePr', node.properties.isScriptAligned, node.properties.ctrlPr);
|
|
581
|
-
if (pr !== undefined) {
|
|
582
|
-
kids.push(pr);
|
|
583
|
-
}
|
|
584
|
-
// CT_SPre: sPrePr?, sub, sup, e
|
|
585
|
-
kids.push(emitArg(ctx, 'sub', node.sub));
|
|
586
|
-
kids.push(emitArg(ctx, 'sup', node.sup));
|
|
587
|
-
kids.push(emitArg(ctx, 'e', node.base));
|
|
588
|
-
return mEl(ctx, 'sPre', kids);
|
|
589
|
-
}
|
|
590
|
-
function emitSSub(ctx, node) {
|
|
591
|
-
var kids = [];
|
|
592
|
-
var pr = emitScriptPr(ctx, 'sSubPr', node.properties.isScriptAligned, node.properties.ctrlPr);
|
|
593
|
-
if (pr !== undefined) {
|
|
594
|
-
kids.push(pr);
|
|
595
|
-
}
|
|
596
|
-
// CT_SSub: sSubPr?, e, sub
|
|
597
|
-
kids.push(emitArg(ctx, 'e', node.base));
|
|
598
|
-
kids.push(emitArg(ctx, 'sub', node.subscript));
|
|
599
|
-
return mEl(ctx, 'sSub', kids);
|
|
600
|
-
}
|
|
601
|
-
function emitSSubSup(ctx, node) {
|
|
602
|
-
var kids = [];
|
|
603
|
-
var pr = emitScriptPr(ctx, 'sSubSupPr', node.properties.isScriptAligned, node.properties.ctrlPr);
|
|
604
|
-
if (pr !== undefined) {
|
|
605
|
-
kids.push(pr);
|
|
606
|
-
}
|
|
607
|
-
// CT_SSubSup: sSubSupPr?, e, sub, sup
|
|
608
|
-
kids.push(emitArg(ctx, 'e', node.base));
|
|
609
|
-
kids.push(emitArg(ctx, 'sub', node.subscript));
|
|
610
|
-
kids.push(emitArg(ctx, 'sup', node.superscript));
|
|
611
|
-
return mEl(ctx, 'sSubSup', kids);
|
|
612
|
-
}
|
|
613
|
-
function emitSSup(ctx, node) {
|
|
614
|
-
var kids = [];
|
|
615
|
-
var pr = emitScriptPr(ctx, 'sSupPr', node.properties.isScriptAligned, node.properties.ctrlPr);
|
|
616
|
-
if (pr !== undefined) {
|
|
617
|
-
kids.push(pr);
|
|
618
|
-
}
|
|
619
|
-
// CT_SSup: sSupPr?, e, sup
|
|
620
|
-
kids.push(emitArg(ctx, 'e', node.base));
|
|
621
|
-
kids.push(emitArg(ctx, 'sup', node.superscript));
|
|
622
|
-
return mEl(ctx, 'sSup', kids);
|
|
623
|
-
}
|
|
624
|
-
function emitOMath(ctx, node) {
|
|
625
|
-
var kids = [];
|
|
626
|
-
for (var i = 0; i < node.children.length; i++) {
|
|
627
|
-
var child = node.children[i];
|
|
628
|
-
if (child === undefined) {
|
|
629
|
-
continue;
|
|
630
|
-
}
|
|
631
|
-
kids.push(serializeNode(child, {
|
|
632
|
-
prefix: ctx.prefix,
|
|
633
|
-
path: ctx.path + "[" + String(i) + "]"
|
|
634
|
-
}));
|
|
635
|
-
}
|
|
636
|
-
return mEl(ctx, 'oMath', kids);
|
|
637
|
-
}
|
|
638
|
-
function emitOMathPara(ctx, node) {
|
|
639
|
-
node.assertSerializable(ctx.path);
|
|
640
|
-
var kids = [];
|
|
641
|
-
if (node.properties.jc !== undefined) {
|
|
642
|
-
assertInUnion(node.properties.jc, MATH_JC_VALUES, ctx.path + ".oMathParaPr.jc", 'ST_Jc');
|
|
643
|
-
kids.push(mEl(ctx, 'oMathParaPr', [valEl(ctx, 'jc', node.properties.jc)]));
|
|
644
|
-
}
|
|
645
|
-
for (var i = 0; i < node.equations.length; i++) {
|
|
646
|
-
var eq = node.equations[i];
|
|
647
|
-
if (eq === undefined) {
|
|
648
|
-
continue;
|
|
649
|
-
}
|
|
650
|
-
kids.push(emitOMath({
|
|
651
|
-
prefix: ctx.prefix,
|
|
652
|
-
path: ctx.path + ".oMath[" + String(i) + "]"
|
|
653
|
-
}, eq));
|
|
654
|
-
}
|
|
655
|
-
return mEl(ctx, 'oMathPara', kids);
|
|
656
|
-
}
|
|
657
|
-
function serializeNode(node, ctx) {
|
|
658
|
-
// Preserve-only degradation / unknown: re-emit captured XML verbatim.
|
|
659
|
-
if (node.preserveOnly) {
|
|
660
|
-
if (node.preservedXml === undefined) {
|
|
661
|
-
throw new MathmlValidationError('preserve-only node missing preservedXml', ctx.path, 'required-child');
|
|
662
|
-
}
|
|
663
|
-
return node.preservedXml;
|
|
664
|
-
}
|
|
665
|
-
if (node instanceof UnknownMathElement) {
|
|
666
|
-
if (node.preservedXml === undefined) {
|
|
667
|
-
throw new MathmlValidationError('unknown math node missing preservedXml', ctx.path, 'required-child');
|
|
668
|
-
}
|
|
669
|
-
return node.preservedXml;
|
|
670
|
-
}
|
|
671
|
-
switch (node.type) {
|
|
672
|
-
case 'oMathPara':
|
|
673
|
-
return emitOMathPara(ctx, node);
|
|
674
|
-
case 'oMath':
|
|
675
|
-
return emitOMath(ctx, node);
|
|
676
|
-
case 't':
|
|
677
|
-
return emitText(ctx, node);
|
|
678
|
-
case 'r':
|
|
679
|
-
return emitRun(ctx, node);
|
|
680
|
-
case 'acc':
|
|
681
|
-
return emitAccent(ctx, node);
|
|
682
|
-
case 'bar':
|
|
683
|
-
return emitBar(ctx, node);
|
|
684
|
-
case 'box':
|
|
685
|
-
return emitBox(ctx, node);
|
|
686
|
-
case 'borderBox':
|
|
687
|
-
return emitBorderBox(ctx, node);
|
|
688
|
-
case 'd':
|
|
689
|
-
return emitDelimiter(ctx, node);
|
|
690
|
-
case 'eqArr':
|
|
691
|
-
return emitEqArr(ctx, node);
|
|
692
|
-
case 'f':
|
|
693
|
-
return emitFraction(ctx, node);
|
|
694
|
-
case 'func':
|
|
695
|
-
return emitFunction(ctx, node);
|
|
696
|
-
case 'groupChr':
|
|
697
|
-
return emitGroupChr(ctx, node);
|
|
698
|
-
case 'limLow':
|
|
699
|
-
return emitLimLow(ctx, node);
|
|
700
|
-
case 'limUpp':
|
|
701
|
-
return emitLimUpp(ctx, node);
|
|
702
|
-
case 'm':
|
|
703
|
-
return emitMatrix(ctx, node);
|
|
704
|
-
case 'mr':
|
|
705
|
-
return emitMatrixRow(ctx, node);
|
|
706
|
-
case 'nary':
|
|
707
|
-
return emitNary(ctx, node);
|
|
708
|
-
case 'phant':
|
|
709
|
-
return emitPhant(ctx, node);
|
|
710
|
-
case 'rad':
|
|
711
|
-
return emitRad(ctx, node);
|
|
712
|
-
case 'sPre':
|
|
713
|
-
return emitSPre(ctx, node);
|
|
714
|
-
case 'sSub':
|
|
715
|
-
return emitSSub(ctx, node);
|
|
716
|
-
case 'sSubSup':
|
|
717
|
-
return emitSSubSup(ctx, node);
|
|
718
|
-
case 'sSup':
|
|
719
|
-
return emitSSup(ctx, node);
|
|
720
|
-
case 'arg':
|
|
721
|
-
// Arguments are only emitted via emitArg with a schema local name.
|
|
722
|
-
throw new MathmlValidationError('MathArgument cannot be serialized as a root; use a named CT_OMathArg slot', ctx.path, 'child-order');
|
|
723
|
-
case 'unknown':
|
|
724
|
-
// Handled above via instanceof; keep exhaustive.
|
|
725
|
-
if (node.preservedXml !== undefined) {
|
|
726
|
-
return node.preservedXml;
|
|
727
|
-
}
|
|
728
|
-
throw new MathmlValidationError('unknown math node missing preservedXml', ctx.path, 'required-child');
|
|
729
|
-
default:
|
|
730
|
-
{
|
|
731
|
-
var _exhaustive = node.type;
|
|
732
|
-
throw new MathmlValidationError("Unhandled math kind: " + String(_exhaustive), ctx.path, 'required-child');
|
|
733
|
-
}
|
|
734
|
-
}
|
|
735
|
-
}
|
|
736
|
-
/**
|
|
737
|
-
* Serialize a typed math node to an OpenXml element tree.
|
|
738
|
-
*
|
|
739
|
-
* Source: mathml-spec §9 — strict schema order; preserve-only re-emits XML.
|
|
740
|
-
*
|
|
741
|
-
* @public
|
|
742
|
-
*/
|
|
743
|
-
export function mathElementToOpenXml(node, options) {
|
|
744
|
-
var prefix = resolvePrefix(options);
|
|
745
|
-
return serializeNode(node, {
|
|
746
|
-
prefix: prefix,
|
|
747
|
-
path: node.type
|
|
748
|
-
});
|
|
749
|
-
}
|