documents.js 1.63.0 → 1.64.0
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 +113 -20
- package/dist/convert/convert.cjs +3 -3
- package/dist/convert/convert.d.cts +5 -2
- package/dist/convert/convert.d.ts +4 -1
- package/dist/convert/convert.js +3 -3
- package/dist/edit/docx/content.d.cts +1 -1
- package/dist/edit/docx/content.d.ts +1 -1
- package/dist/edit/docx/paragraph.d.cts +3 -3
- package/dist/edit/docx/paragraph.d.ts +3 -3
- package/dist/edit/ods/address.cjs +42 -24
- package/dist/edit/ods/address.d.cts +12 -2
- package/dist/edit/ods/address.d.ts +12 -2
- package/dist/edit/ods/address.js +39 -25
- package/dist/edit/ods/column-row.cjs +68 -6
- package/dist/edit/ods/column-row.d.cts +5 -1
- package/dist/edit/ods/column-row.d.ts +5 -1
- package/dist/edit/ods/column-row.js +68 -10
- package/dist/edit/ods/content.cjs +10 -2
- package/dist/edit/ods/content.js +10 -2
- package/dist/edit/ods/floating.cjs +90 -0
- package/dist/edit/ods/floating.d.cts +7 -0
- package/dist/edit/ods/floating.d.ts +7 -0
- package/dist/edit/ods/floating.js +88 -0
- package/dist/edit/ods/print-settings.cjs +158 -2
- package/dist/edit/ods/print-settings.js +159 -3
- package/dist/edit/ods/sheet.cjs +13 -0
- package/dist/edit/ods/sheet.d.cts +5 -1
- package/dist/edit/ods/sheet.d.ts +5 -1
- package/dist/edit/ods/sheet.js +14 -1
- package/dist/edit/odt/content.cjs +8 -4
- package/dist/edit/odt/content.js +8 -4
- package/dist/edit/odt/editor.cjs +7 -0
- package/dist/edit/odt/editor.d.cts +3 -0
- package/dist/edit/odt/editor.d.ts +3 -0
- package/dist/edit/odt/editor.js +7 -0
- package/dist/edit/odt/formula.cjs +19 -0
- package/dist/edit/odt/formula.d.cts +8 -0
- package/dist/edit/odt/formula.d.ts +8 -0
- package/dist/edit/odt/formula.js +17 -0
- package/dist/evaluate-BU5N1Jk1.d.ts +11 -0
- package/dist/evaluate-BhMXY6DM.d.cts +11 -0
- package/dist/firebird/backup.d.cts +1 -1
- package/dist/firebird/backup.d.ts +1 -1
- package/dist/firebird/data.cjs +30 -16
- package/dist/firebird/data.d.cts +3 -2
- package/dist/firebird/data.d.ts +3 -2
- package/dist/firebird/data.js +30 -17
- package/dist/fonts/ooxml.d.cts +1 -1
- package/dist/fonts/registry.d.cts +1 -1
- package/dist/formula-CgydMiTt.d.ts +10 -0
- package/dist/formula-CiwPw8nY.d.cts +10 -0
- package/dist/hsqldb/binary-script.d.cts +1 -1
- package/dist/hsqldb/binary-script.d.ts +1 -1
- package/dist/hsqldb/cache.d.cts +1 -1
- package/dist/hsqldb/cache.d.ts +1 -1
- package/dist/hsqldb/rowformat.cjs +22 -13
- package/dist/hsqldb/rowformat.js +22 -13
- package/dist/hsqldb/script.d.cts +1 -18
- package/dist/hsqldb/script.d.ts +1 -18
- package/dist/index.cjs +56 -0
- package/dist/index.d.cts +22 -8
- package/dist/index.d.ts +21 -7
- package/dist/index.js +15 -2
- package/dist/layout/sheets.cjs +30 -24
- package/dist/layout/sheets.js +31 -25
- package/dist/layout/slides.cjs +6 -4
- package/dist/layout/slides.js +7 -5
- package/dist/lexer-DGPWx_f2.d.cts +42 -0
- package/dist/lexer-DGPWx_f2.d.ts +42 -0
- package/dist/mathml/layout.d.cts +1 -1
- package/dist/mathml/layout.d.ts +1 -1
- package/dist/mathml/variant.d.cts +1 -6
- package/dist/mathml/variant.d.ts +1 -6
- package/dist/odb/csv.d.cts +1 -1
- package/dist/odb/csv.d.ts +1 -1
- package/dist/odb/formula/definition.cjs +49 -0
- package/dist/odb/formula/definition.d.cts +8 -0
- package/dist/odb/formula/definition.d.ts +8 -0
- package/dist/odb/formula/definition.js +46 -0
- package/dist/odb/formula/errors.cjs +47 -0
- package/dist/odb/formula/errors.d.cts +21 -0
- package/dist/odb/formula/errors.d.ts +21 -0
- package/dist/odb/formula/errors.js +43 -0
- package/dist/odb/formula/evaluate.cjs +283 -0
- package/dist/odb/formula/evaluate.d.cts +43 -0
- package/dist/odb/formula/evaluate.d.ts +43 -0
- package/dist/odb/formula/evaluate.js +281 -0
- package/dist/odb/formula/parser.cjs +198 -0
- package/dist/odb/formula/parser.d.cts +29 -0
- package/dist/odb/formula/parser.d.ts +29 -0
- package/dist/odb/formula/parser.js +197 -0
- package/dist/odb/read.d.cts +1 -1
- package/dist/odb/read.d.ts +1 -1
- package/dist/odb/report/content.cjs +27 -0
- package/dist/odb/report/content.d.cts +14 -0
- package/dist/odb/report/content.d.ts +14 -0
- package/dist/odb/report/content.js +25 -0
- package/dist/odb/report/render.cjs +106 -0
- package/dist/odb/report/render.d.cts +7 -0
- package/dist/odb/report/render.d.ts +7 -0
- package/dist/odb/report/render.js +106 -0
- package/dist/odb/report/source.cjs +45 -0
- package/dist/odb/report/source.d.cts +14 -0
- package/dist/odb/report/source.d.ts +14 -0
- package/dist/odb/report/source.js +42 -0
- package/dist/odb/spreadsheet.d.cts +1 -1
- package/dist/odb/spreadsheet.d.ts +1 -1
- package/dist/odb/sql/errors.cjs +38 -0
- package/dist/odb/sql/errors.d.cts +17 -0
- package/dist/odb/sql/errors.d.ts +17 -0
- package/dist/odb/sql/errors.js +35 -0
- package/dist/odb/sql/evaluate.cjs +312 -0
- package/dist/odb/sql/evaluate.d.cts +2 -0
- package/dist/odb/sql/evaluate.d.ts +2 -0
- package/dist/odb/sql/evaluate.js +311 -0
- package/dist/odb/sql/lexer.cjs +282 -0
- package/dist/odb/sql/lexer.d.cts +2 -0
- package/dist/odb/sql/lexer.d.ts +2 -0
- package/dist/odb/sql/lexer.js +281 -0
- package/dist/odb/sql/parser.cjs +479 -0
- package/dist/odb/sql/parser.d.cts +2 -0
- package/dist/odb/sql/parser.d.ts +2 -0
- package/dist/odb/sql/parser.js +478 -0
- package/dist/odb/values.cjs +75 -0
- package/dist/odb/values.d.cts +2 -0
- package/dist/odb/values.d.ts +2 -0
- package/dist/odb/values.js +69 -0
- package/dist/odf/odt/read.cjs +43 -21
- package/dist/odf/odt/read.js +43 -21
- package/dist/odf-package/formula.cjs +59 -0
- package/dist/odf-package/formula.d.cts +11 -0
- package/dist/odf-package/formula.d.ts +11 -0
- package/dist/odf-package/formula.js +58 -0
- package/dist/odf-package/manifest.cjs +29 -0
- package/dist/odf-package/manifest.d.cts +5 -2
- package/dist/odf-package/manifest.d.ts +5 -2
- package/dist/odf-package/manifest.js +30 -2
- package/dist/odf-package/media.cjs +2 -1
- package/dist/odf-package/media.js +2 -2
- package/dist/omml/read.cjs +265 -0
- package/dist/omml/read.d.cts +12 -0
- package/dist/omml/read.d.ts +12 -0
- package/dist/omml/read.js +263 -0
- package/dist/omml/shared.cjs +67 -0
- package/dist/omml/shared.d.cts +2 -0
- package/dist/omml/shared.d.ts +2 -0
- package/dist/omml/shared.js +64 -0
- package/dist/omml/write.cjs +3 -51
- package/dist/omml/write.d.cts +2 -2
- package/dist/omml/write.d.ts +2 -2
- package/dist/omml/write.js +1 -49
- package/dist/ooxml/docx/extras.cjs +15 -0
- package/dist/ooxml/docx/extras.d.cts +12 -0
- package/dist/ooxml/docx/extras.d.ts +12 -0
- package/dist/ooxml/docx/extras.js +14 -0
- package/dist/ooxml/docx/formula.cjs +109 -0
- package/dist/ooxml/docx/formula.d.cts +2 -0
- package/dist/ooxml/docx/formula.d.ts +2 -0
- package/dist/ooxml/docx/formula.js +108 -0
- package/dist/ooxml/docx/read.cjs +10 -2
- package/dist/ooxml/docx/read.d.cts +6 -2
- package/dist/ooxml/docx/read.d.ts +6 -2
- package/dist/ooxml/docx/read.js +11 -3
- package/dist/parser-B9vC1T6T.d.cts +101 -0
- package/dist/parser-DQSgYJzQ.d.ts +101 -0
- package/dist/{registry-CtPhMD0f.d.cts → registry-lqJej0Jr.d.cts} +1 -1
- package/dist/script-DsGGIzGU.d.cts +19 -0
- package/dist/script-DsGGIzGU.d.ts +19 -0
- package/dist/shared-DLZ3IQUl.d.cts +15 -0
- package/dist/shared-DUOzjwcL.d.ts +15 -0
- package/dist/values-BetetbaH.d.cts +23 -0
- package/dist/values-BetetbaH.d.ts +23 -0
- package/dist/variant-BMrebjMw.d.cts +7 -0
- package/dist/variant-BMrebjMw.d.ts +7 -0
- package/dist/{write-DuyfnbL_.d.cts → write-BQ6SK8r8.d.cts} +2 -6
- package/dist/{write-Zqwx6pka.d.ts → write-THs7ipBq.d.ts} +2 -6
- package/package.json +1 -1
|
@@ -0,0 +1,265 @@
|
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
const require_mathml_nodes = require("../mathml/nodes.cjs");
|
|
3
|
+
const require_omml_shared = require("./shared.cjs");
|
|
4
|
+
let ooxml_js = require("ooxml.js");
|
|
5
|
+
//#region src/omml/read.ts
|
|
6
|
+
const ARGUMENT_SLOTS = /* @__PURE__ */ new Set([
|
|
7
|
+
"e",
|
|
8
|
+
"num",
|
|
9
|
+
"den",
|
|
10
|
+
"sub",
|
|
11
|
+
"sup",
|
|
12
|
+
"lim",
|
|
13
|
+
"deg",
|
|
14
|
+
"fName"
|
|
15
|
+
]);
|
|
16
|
+
function isPropertiesElement(name) {
|
|
17
|
+
return name.endsWith("Pr");
|
|
18
|
+
}
|
|
19
|
+
function elementLocalName(element) {
|
|
20
|
+
return require_mathml_nodes.localName(element.tag);
|
|
21
|
+
}
|
|
22
|
+
function elementChildren(element) {
|
|
23
|
+
return element.children.filter((child) => child.type === "element");
|
|
24
|
+
}
|
|
25
|
+
function childByLocalName(element, name) {
|
|
26
|
+
return element === void 0 ? void 0 : elementChildren(element).find((child) => elementLocalName(child) === name);
|
|
27
|
+
}
|
|
28
|
+
function childrenByLocalName(element, name) {
|
|
29
|
+
return elementChildren(element).filter((child) => elementLocalName(child) === name);
|
|
30
|
+
}
|
|
31
|
+
function attrByLocalName(element, name) {
|
|
32
|
+
const raw = element?.attributes.find((attribute) => require_mathml_nodes.localName(attribute.name) === name)?.value;
|
|
33
|
+
return raw === void 0 ? void 0 : (0, ooxml_js.decodeEntities)(raw);
|
|
34
|
+
}
|
|
35
|
+
function propertyValue(properties, name) {
|
|
36
|
+
return attrByLocalName(childByLocalName(properties, name), "val");
|
|
37
|
+
}
|
|
38
|
+
function isPropertyOn(properties, name) {
|
|
39
|
+
const element = childByLocalName(properties, name);
|
|
40
|
+
if (element === void 0) return false;
|
|
41
|
+
const value = attrByLocalName(element, "val");
|
|
42
|
+
return value === void 0 || value === "1" || value === "true" || value === "on";
|
|
43
|
+
}
|
|
44
|
+
function textOf(node) {
|
|
45
|
+
if (node.type === "text") return (0, ooxml_js.decodeEntities)(node.value);
|
|
46
|
+
if (node.type !== "element") return "";
|
|
47
|
+
let out = "";
|
|
48
|
+
for (const child of node.children) out += textOf(child);
|
|
49
|
+
return out;
|
|
50
|
+
}
|
|
51
|
+
function mathElement(tag, attributes, children) {
|
|
52
|
+
return {
|
|
53
|
+
type: "element",
|
|
54
|
+
tag,
|
|
55
|
+
attributes: Object.entries(attributes).map(([name, value]) => ({
|
|
56
|
+
name,
|
|
57
|
+
value
|
|
58
|
+
})),
|
|
59
|
+
children
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
function mathToken(tag, attributes, text) {
|
|
63
|
+
return mathElement(tag, attributes, [{
|
|
64
|
+
type: "text",
|
|
65
|
+
value: text
|
|
66
|
+
}]);
|
|
67
|
+
}
|
|
68
|
+
function operator(character) {
|
|
69
|
+
return mathToken("mo", {}, character);
|
|
70
|
+
}
|
|
71
|
+
function diagnose(ctx, kind, element) {
|
|
72
|
+
ctx.diagnostics.push({
|
|
73
|
+
kind,
|
|
74
|
+
detail: elementLocalName(element)
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
const NUMBER_RUN = /^\d+(?:[.,]\d+)?$/u;
|
|
78
|
+
const LETTER_RUN = /^\p{L}+$/u;
|
|
79
|
+
const SYMBOL_RUN = /^[^\p{L}\p{N}\s]+$/u;
|
|
80
|
+
function tokenTag(text) {
|
|
81
|
+
if (NUMBER_RUN.test(text)) return "mn";
|
|
82
|
+
if (LETTER_RUN.test(text)) return "mi";
|
|
83
|
+
return SYMBOL_RUN.test(text) ? "mo" : "mi";
|
|
84
|
+
}
|
|
85
|
+
function convertRun(run, ctx) {
|
|
86
|
+
const text = childrenByLocalName(run, "t").map((t) => textOf(t)).join("");
|
|
87
|
+
if (text.length === 0) return [];
|
|
88
|
+
const properties = childByLocalName(run, "rPr");
|
|
89
|
+
if (isPropertyOn(properties, "nor")) return [mathToken("mtext", {}, text)];
|
|
90
|
+
const script = propertyValue(properties, "scr");
|
|
91
|
+
const style = propertyValue(properties, "sty");
|
|
92
|
+
const variant = require_omml_shared.variantFromRunProperties(script, style);
|
|
93
|
+
if (variant === void 0) diagnose(ctx, "approximated-element", run);
|
|
94
|
+
const tag = tokenTag(text);
|
|
95
|
+
const intrinsic = tag === "mi" ? require_omml_shared.miIntrinsicDefault(text) : "normal";
|
|
96
|
+
return [mathToken(tag, variant !== void 0 && variant !== intrinsic ? { mathvariant: variant } : {}, text)];
|
|
97
|
+
}
|
|
98
|
+
function slotArgument(parent, slot, ctx) {
|
|
99
|
+
const nodes = slotContent(parent, slot, ctx);
|
|
100
|
+
const [only] = nodes;
|
|
101
|
+
return nodes.length === 1 && only !== void 0 ? only : mathElement("mrow", {}, nodes);
|
|
102
|
+
}
|
|
103
|
+
function slotContent(parent, slot, ctx) {
|
|
104
|
+
const element = childByLocalName(parent, slot);
|
|
105
|
+
return element === void 0 ? [] : convertNodes(element.children, ctx);
|
|
106
|
+
}
|
|
107
|
+
function convertFraction(element, ctx) {
|
|
108
|
+
return mathElement("mfrac", propertyValue(childByLocalName(element, "fPr"), "type") === "noBar" ? { linethickness: "0" } : {}, [slotArgument(element, "num", ctx), slotArgument(element, "den", ctx)]);
|
|
109
|
+
}
|
|
110
|
+
function convertRadical(element, ctx) {
|
|
111
|
+
const degree = childByLocalName(element, "deg");
|
|
112
|
+
if (isPropertyOn(childByLocalName(element, "radPr"), "degHide") || degree === void 0 || elementChildren(degree).length === 0) return mathElement("msqrt", {}, slotContent(element, "e", ctx));
|
|
113
|
+
return mathElement("mroot", {}, [slotArgument(element, "e", ctx), slotArgument(element, "deg", ctx)]);
|
|
114
|
+
}
|
|
115
|
+
function nestedLimLow(element) {
|
|
116
|
+
const base = childByLocalName(element, "e");
|
|
117
|
+
if (base === void 0) return;
|
|
118
|
+
const children = elementChildren(base);
|
|
119
|
+
const [only] = children;
|
|
120
|
+
return children.length === 1 && only !== void 0 && elementLocalName(only) === "limLow" ? only : void 0;
|
|
121
|
+
}
|
|
122
|
+
function convertDelimiter(element, ctx) {
|
|
123
|
+
const properties = childByLocalName(element, "dPr");
|
|
124
|
+
const beginChar = propertyValue(properties, "begChr") ?? "(";
|
|
125
|
+
const endChar = propertyValue(properties, "endChr") ?? ")";
|
|
126
|
+
const separatorChar = propertyValue(properties, "sepChr") ?? "|";
|
|
127
|
+
const children = [];
|
|
128
|
+
if (beginChar.length > 0) children.push(operator(beginChar));
|
|
129
|
+
childrenByLocalName(element, "e").forEach((slot, index) => {
|
|
130
|
+
if (index > 0 && separatorChar.length > 0) children.push(operator(separatorChar));
|
|
131
|
+
children.push(...convertNodes(slot.children, ctx));
|
|
132
|
+
});
|
|
133
|
+
if (endChar.length > 0) children.push(operator(endChar));
|
|
134
|
+
return mathElement("mrow", {}, children);
|
|
135
|
+
}
|
|
136
|
+
function convertNary(element, ctx) {
|
|
137
|
+
const properties = childByLocalName(element, "naryPr");
|
|
138
|
+
const character = propertyValue(properties, "chr") ?? "∫";
|
|
139
|
+
const underOver = propertyValue(properties, "limLoc") === "undOvr";
|
|
140
|
+
const hasLower = !isPropertyOn(properties, "subHide");
|
|
141
|
+
const hasUpper = !isPropertyOn(properties, "supHide");
|
|
142
|
+
const base = operator(character);
|
|
143
|
+
let scripted = base;
|
|
144
|
+
if (hasLower && hasUpper) scripted = mathElement(underOver ? "munderover" : "msubsup", {}, [
|
|
145
|
+
base,
|
|
146
|
+
slotArgument(element, "sub", ctx),
|
|
147
|
+
slotArgument(element, "sup", ctx)
|
|
148
|
+
]);
|
|
149
|
+
else if (hasLower) scripted = mathElement(underOver ? "munder" : "msub", {}, [base, slotArgument(element, "sub", ctx)]);
|
|
150
|
+
else if (hasUpper) scripted = mathElement(underOver ? "mover" : "msup", {}, [base, slotArgument(element, "sup", ctx)]);
|
|
151
|
+
return mathElement("mrow", {}, [scripted, ...slotContent(element, "e", ctx)]);
|
|
152
|
+
}
|
|
153
|
+
function convertAccent(element, ctx) {
|
|
154
|
+
const character = propertyValue(childByLocalName(element, "accPr"), "chr") ?? "̂";
|
|
155
|
+
return mathElement("mover", { accent: "true" }, [slotArgument(element, "e", ctx), operator(character)]);
|
|
156
|
+
}
|
|
157
|
+
function convertBar(element, ctx) {
|
|
158
|
+
const top = propertyValue(childByLocalName(element, "barPr"), "pos") === "top";
|
|
159
|
+
return mathElement(top ? "mover" : "munder", { accent: "true" }, [slotArgument(element, "e", ctx), operator(top ? "‾" : "_")]);
|
|
160
|
+
}
|
|
161
|
+
function convertMatrix(element, ctx) {
|
|
162
|
+
const columns = childByLocalName(childByLocalName(element, "mPr"), "mcs");
|
|
163
|
+
const alignments = [];
|
|
164
|
+
for (const column of columns === void 0 ? [] : childrenByLocalName(columns, "mc")) {
|
|
165
|
+
const properties = childByLocalName(column, "mcPr");
|
|
166
|
+
const justification = propertyValue(properties, "mcJc") ?? "center";
|
|
167
|
+
const count = Number.parseInt(propertyValue(properties, "count") ?? "1", 10);
|
|
168
|
+
for (let index = 0; index < (Number.isFinite(count) && count > 0 ? count : 1); index++) alignments.push(justification);
|
|
169
|
+
}
|
|
170
|
+
const rows = childrenByLocalName(element, "mr").map((row) => mathElement("mtr", {}, childrenByLocalName(row, "e").map((cell) => mathElement("mtd", {}, convertNodes(cell.children, ctx)))));
|
|
171
|
+
return mathElement("mtable", alignments.some((alignment) => alignment !== "center") ? { columnalign: alignments.join(" ") } : {}, rows);
|
|
172
|
+
}
|
|
173
|
+
function convertUnknownContainer(element, ctx) {
|
|
174
|
+
const slots = elementChildren(element).filter((child) => ARGUMENT_SLOTS.has(elementLocalName(child)));
|
|
175
|
+
if (slots.length > 0) {
|
|
176
|
+
diagnose(ctx, "approximated-element", element);
|
|
177
|
+
return [mathElement("mrow", {}, slots.flatMap((slot) => convertNodes(slot.children, ctx)))];
|
|
178
|
+
}
|
|
179
|
+
diagnose(ctx, "unsupported-element", element);
|
|
180
|
+
const text = textOf(element);
|
|
181
|
+
return text.length === 0 ? [] : [mathToken("mtext", {}, text)];
|
|
182
|
+
}
|
|
183
|
+
function convertElement(element, ctx) {
|
|
184
|
+
const name = elementLocalName(element);
|
|
185
|
+
if (isPropertiesElement(name)) return [];
|
|
186
|
+
switch (name) {
|
|
187
|
+
case "oMathPara":
|
|
188
|
+
case "oMath": return convertNodes(element.children, ctx);
|
|
189
|
+
case "r": return convertRun(element, ctx);
|
|
190
|
+
case "f": return [convertFraction(element, ctx)];
|
|
191
|
+
case "rad": return [convertRadical(element, ctx)];
|
|
192
|
+
case "sSub": return [mathElement("msub", {}, [slotArgument(element, "e", ctx), slotArgument(element, "sub", ctx)])];
|
|
193
|
+
case "sSup": return [mathElement("msup", {}, [slotArgument(element, "e", ctx), slotArgument(element, "sup", ctx)])];
|
|
194
|
+
case "sSubSup": return [mathElement("msubsup", {}, [
|
|
195
|
+
slotArgument(element, "e", ctx),
|
|
196
|
+
slotArgument(element, "sub", ctx),
|
|
197
|
+
slotArgument(element, "sup", ctx)
|
|
198
|
+
])];
|
|
199
|
+
case "sPre": return [mathElement("mmultiscripts", {}, [
|
|
200
|
+
slotArgument(element, "e", ctx),
|
|
201
|
+
mathElement("mprescripts", {}, []),
|
|
202
|
+
slotArgument(element, "sub", ctx),
|
|
203
|
+
slotArgument(element, "sup", ctx)
|
|
204
|
+
])];
|
|
205
|
+
case "limLow": return [mathElement("munder", {}, [slotArgument(element, "e", ctx), slotArgument(element, "lim", ctx)])];
|
|
206
|
+
case "limUpp": {
|
|
207
|
+
const inner = nestedLimLow(element);
|
|
208
|
+
if (inner !== void 0) return [mathElement("munderover", {}, [
|
|
209
|
+
slotArgument(inner, "e", ctx),
|
|
210
|
+
slotArgument(inner, "lim", ctx),
|
|
211
|
+
slotArgument(element, "lim", ctx)
|
|
212
|
+
])];
|
|
213
|
+
return [mathElement("mover", {}, [slotArgument(element, "e", ctx), slotArgument(element, "lim", ctx)])];
|
|
214
|
+
}
|
|
215
|
+
case "m": return [convertMatrix(element, ctx)];
|
|
216
|
+
case "d": return [convertDelimiter(element, ctx)];
|
|
217
|
+
case "nary": return [convertNary(element, ctx)];
|
|
218
|
+
case "acc": return [convertAccent(element, ctx)];
|
|
219
|
+
case "bar": return [convertBar(element, ctx)];
|
|
220
|
+
case "func": return [mathElement("mrow", {}, [...slotContent(element, "fName", ctx), ...slotContent(element, "e", ctx)])];
|
|
221
|
+
case "e":
|
|
222
|
+
case "num":
|
|
223
|
+
case "den":
|
|
224
|
+
case "sub":
|
|
225
|
+
case "sup":
|
|
226
|
+
case "lim":
|
|
227
|
+
case "deg":
|
|
228
|
+
case "fName":
|
|
229
|
+
case "mr": return convertNodes(element.children, ctx);
|
|
230
|
+
default: return convertUnknownContainer(element, ctx);
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
function convertNodes(nodes, ctx) {
|
|
234
|
+
const out = [];
|
|
235
|
+
for (const node of nodes) {
|
|
236
|
+
if (node.type !== "element") continue;
|
|
237
|
+
out.push(...convertElement(node, ctx));
|
|
238
|
+
}
|
|
239
|
+
return out;
|
|
240
|
+
}
|
|
241
|
+
function readOfficeMath(element) {
|
|
242
|
+
const diagnostics = [];
|
|
243
|
+
return {
|
|
244
|
+
mathml: convertNodes([element], { diagnostics }),
|
|
245
|
+
diagnostics
|
|
246
|
+
};
|
|
247
|
+
}
|
|
248
|
+
function collectOfficeMathElements(nodes) {
|
|
249
|
+
const out = [];
|
|
250
|
+
const walk = (candidates) => {
|
|
251
|
+
for (const node of candidates) {
|
|
252
|
+
if (node.type !== "element") continue;
|
|
253
|
+
if (require_mathml_nodes.localName(node.tag) === "oMath") {
|
|
254
|
+
out.push(node);
|
|
255
|
+
continue;
|
|
256
|
+
}
|
|
257
|
+
walk(node.children);
|
|
258
|
+
}
|
|
259
|
+
};
|
|
260
|
+
walk(nodes);
|
|
261
|
+
return out;
|
|
262
|
+
}
|
|
263
|
+
//#endregion
|
|
264
|
+
exports.collectOfficeMathElements = collectOfficeMathElements;
|
|
265
|
+
exports.readOfficeMath = readOfficeMath;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { t as OmmlDiagnostic } from "../shared-DLZ3IQUl.cjs";
|
|
2
|
+
import { MathMlNode } from "document-schema.js";
|
|
3
|
+
import { XmlElement, XmlNode } from "ooxml.js";
|
|
4
|
+
//#region src/omml/read.d.ts
|
|
5
|
+
interface OmmlReadResult {
|
|
6
|
+
readonly mathml: MathMlNode[];
|
|
7
|
+
readonly diagnostics: readonly OmmlDiagnostic[];
|
|
8
|
+
}
|
|
9
|
+
declare function readOfficeMath(element: XmlElement): OmmlReadResult;
|
|
10
|
+
declare function collectOfficeMathElements(nodes: readonly XmlNode[]): readonly XmlElement[];
|
|
11
|
+
//#endregion
|
|
12
|
+
export { OmmlReadResult, collectOfficeMathElements, readOfficeMath };
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { t as OmmlDiagnostic } from "../shared-DUOzjwcL.js";
|
|
2
|
+
import { XmlElement, XmlNode } from "ooxml.js";
|
|
3
|
+
import { MathMlNode } from "document-schema.js";
|
|
4
|
+
//#region src/omml/read.d.ts
|
|
5
|
+
interface OmmlReadResult {
|
|
6
|
+
readonly mathml: MathMlNode[];
|
|
7
|
+
readonly diagnostics: readonly OmmlDiagnostic[];
|
|
8
|
+
}
|
|
9
|
+
declare function readOfficeMath(element: XmlElement): OmmlReadResult;
|
|
10
|
+
declare function collectOfficeMathElements(nodes: readonly XmlNode[]): readonly XmlElement[];
|
|
11
|
+
//#endregion
|
|
12
|
+
export { OmmlReadResult, collectOfficeMathElements, readOfficeMath };
|
|
@@ -0,0 +1,263 @@
|
|
|
1
|
+
import { localName } from "../mathml/nodes.js";
|
|
2
|
+
import { miIntrinsicDefault, variantFromRunProperties } from "./shared.js";
|
|
3
|
+
import { decodeEntities } from "ooxml.js";
|
|
4
|
+
//#region src/omml/read.ts
|
|
5
|
+
const ARGUMENT_SLOTS = /* @__PURE__ */ new Set([
|
|
6
|
+
"e",
|
|
7
|
+
"num",
|
|
8
|
+
"den",
|
|
9
|
+
"sub",
|
|
10
|
+
"sup",
|
|
11
|
+
"lim",
|
|
12
|
+
"deg",
|
|
13
|
+
"fName"
|
|
14
|
+
]);
|
|
15
|
+
function isPropertiesElement(name) {
|
|
16
|
+
return name.endsWith("Pr");
|
|
17
|
+
}
|
|
18
|
+
function elementLocalName(element) {
|
|
19
|
+
return localName(element.tag);
|
|
20
|
+
}
|
|
21
|
+
function elementChildren(element) {
|
|
22
|
+
return element.children.filter((child) => child.type === "element");
|
|
23
|
+
}
|
|
24
|
+
function childByLocalName(element, name) {
|
|
25
|
+
return element === void 0 ? void 0 : elementChildren(element).find((child) => elementLocalName(child) === name);
|
|
26
|
+
}
|
|
27
|
+
function childrenByLocalName(element, name) {
|
|
28
|
+
return elementChildren(element).filter((child) => elementLocalName(child) === name);
|
|
29
|
+
}
|
|
30
|
+
function attrByLocalName(element, name) {
|
|
31
|
+
const raw = element?.attributes.find((attribute) => localName(attribute.name) === name)?.value;
|
|
32
|
+
return raw === void 0 ? void 0 : decodeEntities(raw);
|
|
33
|
+
}
|
|
34
|
+
function propertyValue(properties, name) {
|
|
35
|
+
return attrByLocalName(childByLocalName(properties, name), "val");
|
|
36
|
+
}
|
|
37
|
+
function isPropertyOn(properties, name) {
|
|
38
|
+
const element = childByLocalName(properties, name);
|
|
39
|
+
if (element === void 0) return false;
|
|
40
|
+
const value = attrByLocalName(element, "val");
|
|
41
|
+
return value === void 0 || value === "1" || value === "true" || value === "on";
|
|
42
|
+
}
|
|
43
|
+
function textOf(node) {
|
|
44
|
+
if (node.type === "text") return decodeEntities(node.value);
|
|
45
|
+
if (node.type !== "element") return "";
|
|
46
|
+
let out = "";
|
|
47
|
+
for (const child of node.children) out += textOf(child);
|
|
48
|
+
return out;
|
|
49
|
+
}
|
|
50
|
+
function mathElement(tag, attributes, children) {
|
|
51
|
+
return {
|
|
52
|
+
type: "element",
|
|
53
|
+
tag,
|
|
54
|
+
attributes: Object.entries(attributes).map(([name, value]) => ({
|
|
55
|
+
name,
|
|
56
|
+
value
|
|
57
|
+
})),
|
|
58
|
+
children
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
function mathToken(tag, attributes, text) {
|
|
62
|
+
return mathElement(tag, attributes, [{
|
|
63
|
+
type: "text",
|
|
64
|
+
value: text
|
|
65
|
+
}]);
|
|
66
|
+
}
|
|
67
|
+
function operator(character) {
|
|
68
|
+
return mathToken("mo", {}, character);
|
|
69
|
+
}
|
|
70
|
+
function diagnose(ctx, kind, element) {
|
|
71
|
+
ctx.diagnostics.push({
|
|
72
|
+
kind,
|
|
73
|
+
detail: elementLocalName(element)
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
const NUMBER_RUN = /^\d+(?:[.,]\d+)?$/u;
|
|
77
|
+
const LETTER_RUN = /^\p{L}+$/u;
|
|
78
|
+
const SYMBOL_RUN = /^[^\p{L}\p{N}\s]+$/u;
|
|
79
|
+
function tokenTag(text) {
|
|
80
|
+
if (NUMBER_RUN.test(text)) return "mn";
|
|
81
|
+
if (LETTER_RUN.test(text)) return "mi";
|
|
82
|
+
return SYMBOL_RUN.test(text) ? "mo" : "mi";
|
|
83
|
+
}
|
|
84
|
+
function convertRun(run, ctx) {
|
|
85
|
+
const text = childrenByLocalName(run, "t").map((t) => textOf(t)).join("");
|
|
86
|
+
if (text.length === 0) return [];
|
|
87
|
+
const properties = childByLocalName(run, "rPr");
|
|
88
|
+
if (isPropertyOn(properties, "nor")) return [mathToken("mtext", {}, text)];
|
|
89
|
+
const script = propertyValue(properties, "scr");
|
|
90
|
+
const style = propertyValue(properties, "sty");
|
|
91
|
+
const variant = variantFromRunProperties(script, style);
|
|
92
|
+
if (variant === void 0) diagnose(ctx, "approximated-element", run);
|
|
93
|
+
const tag = tokenTag(text);
|
|
94
|
+
const intrinsic = tag === "mi" ? miIntrinsicDefault(text) : "normal";
|
|
95
|
+
return [mathToken(tag, variant !== void 0 && variant !== intrinsic ? { mathvariant: variant } : {}, text)];
|
|
96
|
+
}
|
|
97
|
+
function slotArgument(parent, slot, ctx) {
|
|
98
|
+
const nodes = slotContent(parent, slot, ctx);
|
|
99
|
+
const [only] = nodes;
|
|
100
|
+
return nodes.length === 1 && only !== void 0 ? only : mathElement("mrow", {}, nodes);
|
|
101
|
+
}
|
|
102
|
+
function slotContent(parent, slot, ctx) {
|
|
103
|
+
const element = childByLocalName(parent, slot);
|
|
104
|
+
return element === void 0 ? [] : convertNodes(element.children, ctx);
|
|
105
|
+
}
|
|
106
|
+
function convertFraction(element, ctx) {
|
|
107
|
+
return mathElement("mfrac", propertyValue(childByLocalName(element, "fPr"), "type") === "noBar" ? { linethickness: "0" } : {}, [slotArgument(element, "num", ctx), slotArgument(element, "den", ctx)]);
|
|
108
|
+
}
|
|
109
|
+
function convertRadical(element, ctx) {
|
|
110
|
+
const degree = childByLocalName(element, "deg");
|
|
111
|
+
if (isPropertyOn(childByLocalName(element, "radPr"), "degHide") || degree === void 0 || elementChildren(degree).length === 0) return mathElement("msqrt", {}, slotContent(element, "e", ctx));
|
|
112
|
+
return mathElement("mroot", {}, [slotArgument(element, "e", ctx), slotArgument(element, "deg", ctx)]);
|
|
113
|
+
}
|
|
114
|
+
function nestedLimLow(element) {
|
|
115
|
+
const base = childByLocalName(element, "e");
|
|
116
|
+
if (base === void 0) return;
|
|
117
|
+
const children = elementChildren(base);
|
|
118
|
+
const [only] = children;
|
|
119
|
+
return children.length === 1 && only !== void 0 && elementLocalName(only) === "limLow" ? only : void 0;
|
|
120
|
+
}
|
|
121
|
+
function convertDelimiter(element, ctx) {
|
|
122
|
+
const properties = childByLocalName(element, "dPr");
|
|
123
|
+
const beginChar = propertyValue(properties, "begChr") ?? "(";
|
|
124
|
+
const endChar = propertyValue(properties, "endChr") ?? ")";
|
|
125
|
+
const separatorChar = propertyValue(properties, "sepChr") ?? "|";
|
|
126
|
+
const children = [];
|
|
127
|
+
if (beginChar.length > 0) children.push(operator(beginChar));
|
|
128
|
+
childrenByLocalName(element, "e").forEach((slot, index) => {
|
|
129
|
+
if (index > 0 && separatorChar.length > 0) children.push(operator(separatorChar));
|
|
130
|
+
children.push(...convertNodes(slot.children, ctx));
|
|
131
|
+
});
|
|
132
|
+
if (endChar.length > 0) children.push(operator(endChar));
|
|
133
|
+
return mathElement("mrow", {}, children);
|
|
134
|
+
}
|
|
135
|
+
function convertNary(element, ctx) {
|
|
136
|
+
const properties = childByLocalName(element, "naryPr");
|
|
137
|
+
const character = propertyValue(properties, "chr") ?? "∫";
|
|
138
|
+
const underOver = propertyValue(properties, "limLoc") === "undOvr";
|
|
139
|
+
const hasLower = !isPropertyOn(properties, "subHide");
|
|
140
|
+
const hasUpper = !isPropertyOn(properties, "supHide");
|
|
141
|
+
const base = operator(character);
|
|
142
|
+
let scripted = base;
|
|
143
|
+
if (hasLower && hasUpper) scripted = mathElement(underOver ? "munderover" : "msubsup", {}, [
|
|
144
|
+
base,
|
|
145
|
+
slotArgument(element, "sub", ctx),
|
|
146
|
+
slotArgument(element, "sup", ctx)
|
|
147
|
+
]);
|
|
148
|
+
else if (hasLower) scripted = mathElement(underOver ? "munder" : "msub", {}, [base, slotArgument(element, "sub", ctx)]);
|
|
149
|
+
else if (hasUpper) scripted = mathElement(underOver ? "mover" : "msup", {}, [base, slotArgument(element, "sup", ctx)]);
|
|
150
|
+
return mathElement("mrow", {}, [scripted, ...slotContent(element, "e", ctx)]);
|
|
151
|
+
}
|
|
152
|
+
function convertAccent(element, ctx) {
|
|
153
|
+
const character = propertyValue(childByLocalName(element, "accPr"), "chr") ?? "̂";
|
|
154
|
+
return mathElement("mover", { accent: "true" }, [slotArgument(element, "e", ctx), operator(character)]);
|
|
155
|
+
}
|
|
156
|
+
function convertBar(element, ctx) {
|
|
157
|
+
const top = propertyValue(childByLocalName(element, "barPr"), "pos") === "top";
|
|
158
|
+
return mathElement(top ? "mover" : "munder", { accent: "true" }, [slotArgument(element, "e", ctx), operator(top ? "‾" : "_")]);
|
|
159
|
+
}
|
|
160
|
+
function convertMatrix(element, ctx) {
|
|
161
|
+
const columns = childByLocalName(childByLocalName(element, "mPr"), "mcs");
|
|
162
|
+
const alignments = [];
|
|
163
|
+
for (const column of columns === void 0 ? [] : childrenByLocalName(columns, "mc")) {
|
|
164
|
+
const properties = childByLocalName(column, "mcPr");
|
|
165
|
+
const justification = propertyValue(properties, "mcJc") ?? "center";
|
|
166
|
+
const count = Number.parseInt(propertyValue(properties, "count") ?? "1", 10);
|
|
167
|
+
for (let index = 0; index < (Number.isFinite(count) && count > 0 ? count : 1); index++) alignments.push(justification);
|
|
168
|
+
}
|
|
169
|
+
const rows = childrenByLocalName(element, "mr").map((row) => mathElement("mtr", {}, childrenByLocalName(row, "e").map((cell) => mathElement("mtd", {}, convertNodes(cell.children, ctx)))));
|
|
170
|
+
return mathElement("mtable", alignments.some((alignment) => alignment !== "center") ? { columnalign: alignments.join(" ") } : {}, rows);
|
|
171
|
+
}
|
|
172
|
+
function convertUnknownContainer(element, ctx) {
|
|
173
|
+
const slots = elementChildren(element).filter((child) => ARGUMENT_SLOTS.has(elementLocalName(child)));
|
|
174
|
+
if (slots.length > 0) {
|
|
175
|
+
diagnose(ctx, "approximated-element", element);
|
|
176
|
+
return [mathElement("mrow", {}, slots.flatMap((slot) => convertNodes(slot.children, ctx)))];
|
|
177
|
+
}
|
|
178
|
+
diagnose(ctx, "unsupported-element", element);
|
|
179
|
+
const text = textOf(element);
|
|
180
|
+
return text.length === 0 ? [] : [mathToken("mtext", {}, text)];
|
|
181
|
+
}
|
|
182
|
+
function convertElement(element, ctx) {
|
|
183
|
+
const name = elementLocalName(element);
|
|
184
|
+
if (isPropertiesElement(name)) return [];
|
|
185
|
+
switch (name) {
|
|
186
|
+
case "oMathPara":
|
|
187
|
+
case "oMath": return convertNodes(element.children, ctx);
|
|
188
|
+
case "r": return convertRun(element, ctx);
|
|
189
|
+
case "f": return [convertFraction(element, ctx)];
|
|
190
|
+
case "rad": return [convertRadical(element, ctx)];
|
|
191
|
+
case "sSub": return [mathElement("msub", {}, [slotArgument(element, "e", ctx), slotArgument(element, "sub", ctx)])];
|
|
192
|
+
case "sSup": return [mathElement("msup", {}, [slotArgument(element, "e", ctx), slotArgument(element, "sup", ctx)])];
|
|
193
|
+
case "sSubSup": return [mathElement("msubsup", {}, [
|
|
194
|
+
slotArgument(element, "e", ctx),
|
|
195
|
+
slotArgument(element, "sub", ctx),
|
|
196
|
+
slotArgument(element, "sup", ctx)
|
|
197
|
+
])];
|
|
198
|
+
case "sPre": return [mathElement("mmultiscripts", {}, [
|
|
199
|
+
slotArgument(element, "e", ctx),
|
|
200
|
+
mathElement("mprescripts", {}, []),
|
|
201
|
+
slotArgument(element, "sub", ctx),
|
|
202
|
+
slotArgument(element, "sup", ctx)
|
|
203
|
+
])];
|
|
204
|
+
case "limLow": return [mathElement("munder", {}, [slotArgument(element, "e", ctx), slotArgument(element, "lim", ctx)])];
|
|
205
|
+
case "limUpp": {
|
|
206
|
+
const inner = nestedLimLow(element);
|
|
207
|
+
if (inner !== void 0) return [mathElement("munderover", {}, [
|
|
208
|
+
slotArgument(inner, "e", ctx),
|
|
209
|
+
slotArgument(inner, "lim", ctx),
|
|
210
|
+
slotArgument(element, "lim", ctx)
|
|
211
|
+
])];
|
|
212
|
+
return [mathElement("mover", {}, [slotArgument(element, "e", ctx), slotArgument(element, "lim", ctx)])];
|
|
213
|
+
}
|
|
214
|
+
case "m": return [convertMatrix(element, ctx)];
|
|
215
|
+
case "d": return [convertDelimiter(element, ctx)];
|
|
216
|
+
case "nary": return [convertNary(element, ctx)];
|
|
217
|
+
case "acc": return [convertAccent(element, ctx)];
|
|
218
|
+
case "bar": return [convertBar(element, ctx)];
|
|
219
|
+
case "func": return [mathElement("mrow", {}, [...slotContent(element, "fName", ctx), ...slotContent(element, "e", ctx)])];
|
|
220
|
+
case "e":
|
|
221
|
+
case "num":
|
|
222
|
+
case "den":
|
|
223
|
+
case "sub":
|
|
224
|
+
case "sup":
|
|
225
|
+
case "lim":
|
|
226
|
+
case "deg":
|
|
227
|
+
case "fName":
|
|
228
|
+
case "mr": return convertNodes(element.children, ctx);
|
|
229
|
+
default: return convertUnknownContainer(element, ctx);
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
function convertNodes(nodes, ctx) {
|
|
233
|
+
const out = [];
|
|
234
|
+
for (const node of nodes) {
|
|
235
|
+
if (node.type !== "element") continue;
|
|
236
|
+
out.push(...convertElement(node, ctx));
|
|
237
|
+
}
|
|
238
|
+
return out;
|
|
239
|
+
}
|
|
240
|
+
function readOfficeMath(element) {
|
|
241
|
+
const diagnostics = [];
|
|
242
|
+
return {
|
|
243
|
+
mathml: convertNodes([element], { diagnostics }),
|
|
244
|
+
diagnostics
|
|
245
|
+
};
|
|
246
|
+
}
|
|
247
|
+
function collectOfficeMathElements(nodes) {
|
|
248
|
+
const out = [];
|
|
249
|
+
const walk = (candidates) => {
|
|
250
|
+
for (const node of candidates) {
|
|
251
|
+
if (node.type !== "element") continue;
|
|
252
|
+
if (localName(node.tag) === "oMath") {
|
|
253
|
+
out.push(node);
|
|
254
|
+
continue;
|
|
255
|
+
}
|
|
256
|
+
walk(node.children);
|
|
257
|
+
}
|
|
258
|
+
};
|
|
259
|
+
walk(nodes);
|
|
260
|
+
return out;
|
|
261
|
+
}
|
|
262
|
+
//#endregion
|
|
263
|
+
export { collectOfficeMathElements, readOfficeMath };
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
const require_mathml_variant = require("../mathml/variant.cjs");
|
|
3
|
+
//#region src/omml/shared.ts
|
|
4
|
+
const VARIANT_RUN_PROPERTIES = {
|
|
5
|
+
normal: { sty: "p" },
|
|
6
|
+
bold: { sty: "b" },
|
|
7
|
+
italic: { sty: "i" },
|
|
8
|
+
"bold-italic": { sty: "bi" },
|
|
9
|
+
"double-struck": {
|
|
10
|
+
scr: "double-struck",
|
|
11
|
+
sty: "p"
|
|
12
|
+
},
|
|
13
|
+
script: {
|
|
14
|
+
scr: "script",
|
|
15
|
+
sty: "p"
|
|
16
|
+
},
|
|
17
|
+
"bold-script": {
|
|
18
|
+
scr: "script",
|
|
19
|
+
sty: "b"
|
|
20
|
+
},
|
|
21
|
+
fraktur: {
|
|
22
|
+
scr: "fraktur",
|
|
23
|
+
sty: "p"
|
|
24
|
+
},
|
|
25
|
+
"bold-fraktur": {
|
|
26
|
+
scr: "fraktur",
|
|
27
|
+
sty: "b"
|
|
28
|
+
},
|
|
29
|
+
"sans-serif": {
|
|
30
|
+
scr: "sans-serif",
|
|
31
|
+
sty: "p"
|
|
32
|
+
},
|
|
33
|
+
"bold-sans-serif": {
|
|
34
|
+
scr: "sans-serif",
|
|
35
|
+
sty: "b"
|
|
36
|
+
},
|
|
37
|
+
"sans-serif-italic": {
|
|
38
|
+
scr: "sans-serif",
|
|
39
|
+
sty: "i"
|
|
40
|
+
},
|
|
41
|
+
"sans-serif-bold-italic": {
|
|
42
|
+
scr: "sans-serif",
|
|
43
|
+
sty: "bi"
|
|
44
|
+
},
|
|
45
|
+
monospace: {
|
|
46
|
+
scr: "monospace",
|
|
47
|
+
sty: "p"
|
|
48
|
+
}
|
|
49
|
+
};
|
|
50
|
+
const DEFAULT_SCRIPT = "roman";
|
|
51
|
+
const DEFAULT_STYLE = "i";
|
|
52
|
+
function buildVariantLookup() {
|
|
53
|
+
const lookup = /* @__PURE__ */ new Map();
|
|
54
|
+
for (const [variant, mapped] of Object.entries(VARIANT_RUN_PROPERTIES)) if (require_mathml_variant.isMathVariant(variant)) lookup.set(`${mapped.scr ?? DEFAULT_SCRIPT}|${mapped.sty}`, variant);
|
|
55
|
+
return lookup;
|
|
56
|
+
}
|
|
57
|
+
const VARIANT_BY_RUN_PROPERTIES = buildVariantLookup();
|
|
58
|
+
function variantFromRunProperties(script, style) {
|
|
59
|
+
return VARIANT_BY_RUN_PROPERTIES.get(`${script ?? DEFAULT_SCRIPT}|${style ?? DEFAULT_STYLE}`);
|
|
60
|
+
}
|
|
61
|
+
function miIntrinsicDefault(content) {
|
|
62
|
+
return [...content].length === 1 ? "italic" : "normal";
|
|
63
|
+
}
|
|
64
|
+
//#endregion
|
|
65
|
+
exports.VARIANT_RUN_PROPERTIES = VARIANT_RUN_PROPERTIES;
|
|
66
|
+
exports.miIntrinsicDefault = miIntrinsicDefault;
|
|
67
|
+
exports.variantFromRunProperties = variantFromRunProperties;
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import { a as variantFromRunProperties, i as miIntrinsicDefault, n as OmmlDiagnosticKind, r as VARIANT_RUN_PROPERTIES, t as OmmlDiagnostic } from "../shared-DLZ3IQUl.cjs";
|
|
2
|
+
export { OmmlDiagnostic, OmmlDiagnosticKind, VARIANT_RUN_PROPERTIES, miIntrinsicDefault, variantFromRunProperties };
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import { a as variantFromRunProperties, i as miIntrinsicDefault, n as OmmlDiagnosticKind, r as VARIANT_RUN_PROPERTIES, t as OmmlDiagnostic } from "../shared-DUOzjwcL.js";
|
|
2
|
+
export { OmmlDiagnostic, OmmlDiagnosticKind, VARIANT_RUN_PROPERTIES, miIntrinsicDefault, variantFromRunProperties };
|