js.documents 7.17.3 → 7.17.5
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 -1
- package/dist/latex/lower.cjs +53 -19
- package/dist/latex/lower.js +53 -19
- package/package.json +14 -14
package/README.md
CHANGED
|
@@ -1015,7 +1015,7 @@ This package also published under an alternate name from the pre-monorepo pipeli
|
|
|
1015
1015
|
|
|
1016
1016
|
- [js.documents](https://www.npmjs.com/package/js.documents)
|
|
1017
1017
|
|
|
1018
|
-
**
|
|
1018
|
+
**Republished automatically** — the alias's trusted publisher is registered against this repository and workflow (2026-09-10), so every `documents.js` release from [js.documents@7.17.4](https://github.com/ExaDev/documents.js/actions/runs/34449796133) onward publishes under this name too; the registration evidence is on [ExaDev/documents.js#731](https://github.com/ExaDev/documents.js/issues/731).
|
|
1019
1019
|
|
|
1020
1020
|
## License
|
|
1021
1021
|
|
package/dist/latex/lower.cjs
CHANGED
|
@@ -133,19 +133,22 @@ function lowerNodeList(nodes, context) {
|
|
|
133
133
|
diagnose(context, "latex/operator-unmapped", detail);
|
|
134
134
|
return unparsed(detail);
|
|
135
135
|
}
|
|
136
|
-
const
|
|
137
|
-
|
|
136
|
+
const normalised = normaliseUnaryMinus(operators, segments.map((nodes) => ({
|
|
137
|
+
nodes,
|
|
138
|
+
negated: false
|
|
139
|
+
})));
|
|
140
|
+
const [firstSegment, ...restSegments] = normalised.segments;
|
|
141
|
+
if (firstSegment === void 0) {
|
|
142
|
+
diagnose(context, "latex/operator-placement-unparsed", spanOfNodes(context, present));
|
|
143
|
+
return unparsed(spanOfNodes(context, present));
|
|
144
|
+
}
|
|
145
|
+
if (normalised.operators.length === 0) return lowerFoldSegment(firstSegment, context);
|
|
138
146
|
const detail = spanOfNodes(context, present);
|
|
139
|
-
if (firstSegment.length === 0) {
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
if (leading !== SUBTRACT_OPERATOR || secondSegment.length === 0) {
|
|
143
|
-
diagnose(context, "latex/operator-placement-unparsed", detail);
|
|
144
|
-
return unparsed(detail);
|
|
145
|
-
}
|
|
146
|
-
return fold(app(UNARY_MINUS_OPERATOR, [lowerTerm(secondSegment, context)]), operators.slice(1), restSegments.slice(1), context, detail);
|
|
147
|
+
if (firstSegment.nodes.length === 0) {
|
|
148
|
+
diagnose(context, "latex/operator-placement-unparsed", detail);
|
|
149
|
+
return unparsed(detail);
|
|
147
150
|
}
|
|
148
|
-
return fold(
|
|
151
|
+
return fold(lowerFoldSegment(firstSegment, context), normalised.operators, restSegments, context, detail);
|
|
149
152
|
}
|
|
150
153
|
function isOperatorAtom(node) {
|
|
151
154
|
return node.type === "atom" && (node.family === "bin" || node.family === "rel");
|
|
@@ -159,6 +162,33 @@ function operatorOfNode(node) {
|
|
|
159
162
|
if (node.type === "textord" && nodeText(node) === "/") return "math:divide";
|
|
160
163
|
}
|
|
161
164
|
const RELATION_OPERATORS = new Set(Object.values(RELATION_ATOM_OPERATORS));
|
|
165
|
+
function normaliseUnaryMinus(operators, segments) {
|
|
166
|
+
const outOperators = [];
|
|
167
|
+
const outSegments = [];
|
|
168
|
+
let pendingNegate = false;
|
|
169
|
+
let skipOperator = false;
|
|
170
|
+
for (const [index, segment] of segments.entries()) {
|
|
171
|
+
if (index > 0 && !skipOperator) {
|
|
172
|
+
const operator = operators[index - 1];
|
|
173
|
+
if (operator !== void 0) outOperators.push(operator);
|
|
174
|
+
}
|
|
175
|
+
skipOperator = false;
|
|
176
|
+
if (segment.nodes.length === 0 && operators[index] === SUBTRACT_OPERATOR) {
|
|
177
|
+
pendingNegate = !pendingNegate;
|
|
178
|
+
skipOperator = true;
|
|
179
|
+
continue;
|
|
180
|
+
}
|
|
181
|
+
outSegments.push({
|
|
182
|
+
nodes: segment.nodes,
|
|
183
|
+
negated: pendingNegate
|
|
184
|
+
});
|
|
185
|
+
pendingNegate = false;
|
|
186
|
+
}
|
|
187
|
+
return {
|
|
188
|
+
operators: outOperators,
|
|
189
|
+
segments: outSegments
|
|
190
|
+
};
|
|
191
|
+
}
|
|
162
192
|
function fold(first, operators, segments, context, detail) {
|
|
163
193
|
let runFirst = first;
|
|
164
194
|
let runOperators = [];
|
|
@@ -167,22 +197,22 @@ function fold(first, operators, segments, context, detail) {
|
|
|
167
197
|
const relations = [];
|
|
168
198
|
for (let index = 0; index < operators.length; index += 1) {
|
|
169
199
|
const operator = operators[index];
|
|
170
|
-
const
|
|
171
|
-
if (operator === void 0 ||
|
|
172
|
-
if (
|
|
200
|
+
const segment = segments[index];
|
|
201
|
+
if (operator === void 0 || segment === void 0) throw new Error("operator and segment lists diverged while folding a lowered sequence");
|
|
202
|
+
if (segment.nodes.length === 0) {
|
|
173
203
|
diagnose(context, "latex/operator-placement-unparsed", detail);
|
|
174
204
|
return unparsed(detail);
|
|
175
205
|
}
|
|
176
206
|
if (RELATION_OPERATORS.has(operator)) {
|
|
177
207
|
operands.push(foldArithmetic(runFirst, runOperators, runSegments, context));
|
|
178
208
|
relations.push(operator);
|
|
179
|
-
runFirst =
|
|
209
|
+
runFirst = lowerFoldSegment(segment, context);
|
|
180
210
|
runOperators = [];
|
|
181
211
|
runSegments = [];
|
|
182
212
|
continue;
|
|
183
213
|
}
|
|
184
214
|
runOperators.push(operator);
|
|
185
|
-
runSegments.push(
|
|
215
|
+
runSegments.push(segment);
|
|
186
216
|
}
|
|
187
217
|
operands.push(foldArithmetic(runFirst, runOperators, runSegments, context));
|
|
188
218
|
let folded = operands[0];
|
|
@@ -199,12 +229,16 @@ function foldArithmetic(first, operators, segments, context) {
|
|
|
199
229
|
let folded = first;
|
|
200
230
|
for (let index = 0; index < operators.length; index += 1) {
|
|
201
231
|
const operator = operators[index];
|
|
202
|
-
const
|
|
203
|
-
if (operator === void 0 ||
|
|
204
|
-
folded = app(operator, [folded,
|
|
232
|
+
const segment = segments[index];
|
|
233
|
+
if (operator === void 0 || segment === void 0) throw new Error("operator and segment lists diverged while folding an arithmetic run");
|
|
234
|
+
folded = app(operator, [folded, lowerFoldSegment(segment, context)]);
|
|
205
235
|
}
|
|
206
236
|
return folded;
|
|
207
237
|
}
|
|
238
|
+
function lowerFoldSegment(segment, context) {
|
|
239
|
+
const folded = lowerTerm(segment.nodes, context);
|
|
240
|
+
return segment.negated ? app(UNARY_MINUS_OPERATOR, [folded]) : folded;
|
|
241
|
+
}
|
|
208
242
|
function lowerTerm(nodes, context) {
|
|
209
243
|
return lowerTermItems(termItems(nodes), context);
|
|
210
244
|
}
|
package/dist/latex/lower.js
CHANGED
|
@@ -132,19 +132,22 @@ function lowerNodeList(nodes, context) {
|
|
|
132
132
|
diagnose(context, "latex/operator-unmapped", detail);
|
|
133
133
|
return unparsed(detail);
|
|
134
134
|
}
|
|
135
|
-
const
|
|
136
|
-
|
|
135
|
+
const normalised = normaliseUnaryMinus(operators, segments.map((nodes) => ({
|
|
136
|
+
nodes,
|
|
137
|
+
negated: false
|
|
138
|
+
})));
|
|
139
|
+
const [firstSegment, ...restSegments] = normalised.segments;
|
|
140
|
+
if (firstSegment === void 0) {
|
|
141
|
+
diagnose(context, "latex/operator-placement-unparsed", spanOfNodes(context, present));
|
|
142
|
+
return unparsed(spanOfNodes(context, present));
|
|
143
|
+
}
|
|
144
|
+
if (normalised.operators.length === 0) return lowerFoldSegment(firstSegment, context);
|
|
137
145
|
const detail = spanOfNodes(context, present);
|
|
138
|
-
if (firstSegment.length === 0) {
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
if (leading !== SUBTRACT_OPERATOR || secondSegment.length === 0) {
|
|
142
|
-
diagnose(context, "latex/operator-placement-unparsed", detail);
|
|
143
|
-
return unparsed(detail);
|
|
144
|
-
}
|
|
145
|
-
return fold(app(UNARY_MINUS_OPERATOR, [lowerTerm(secondSegment, context)]), operators.slice(1), restSegments.slice(1), context, detail);
|
|
146
|
+
if (firstSegment.nodes.length === 0) {
|
|
147
|
+
diagnose(context, "latex/operator-placement-unparsed", detail);
|
|
148
|
+
return unparsed(detail);
|
|
146
149
|
}
|
|
147
|
-
return fold(
|
|
150
|
+
return fold(lowerFoldSegment(firstSegment, context), normalised.operators, restSegments, context, detail);
|
|
148
151
|
}
|
|
149
152
|
function isOperatorAtom(node) {
|
|
150
153
|
return node.type === "atom" && (node.family === "bin" || node.family === "rel");
|
|
@@ -158,6 +161,33 @@ function operatorOfNode(node) {
|
|
|
158
161
|
if (node.type === "textord" && nodeText(node) === "/") return "math:divide";
|
|
159
162
|
}
|
|
160
163
|
const RELATION_OPERATORS = new Set(Object.values(RELATION_ATOM_OPERATORS));
|
|
164
|
+
function normaliseUnaryMinus(operators, segments) {
|
|
165
|
+
const outOperators = [];
|
|
166
|
+
const outSegments = [];
|
|
167
|
+
let pendingNegate = false;
|
|
168
|
+
let skipOperator = false;
|
|
169
|
+
for (const [index, segment] of segments.entries()) {
|
|
170
|
+
if (index > 0 && !skipOperator) {
|
|
171
|
+
const operator = operators[index - 1];
|
|
172
|
+
if (operator !== void 0) outOperators.push(operator);
|
|
173
|
+
}
|
|
174
|
+
skipOperator = false;
|
|
175
|
+
if (segment.nodes.length === 0 && operators[index] === SUBTRACT_OPERATOR) {
|
|
176
|
+
pendingNegate = !pendingNegate;
|
|
177
|
+
skipOperator = true;
|
|
178
|
+
continue;
|
|
179
|
+
}
|
|
180
|
+
outSegments.push({
|
|
181
|
+
nodes: segment.nodes,
|
|
182
|
+
negated: pendingNegate
|
|
183
|
+
});
|
|
184
|
+
pendingNegate = false;
|
|
185
|
+
}
|
|
186
|
+
return {
|
|
187
|
+
operators: outOperators,
|
|
188
|
+
segments: outSegments
|
|
189
|
+
};
|
|
190
|
+
}
|
|
161
191
|
function fold(first, operators, segments, context, detail) {
|
|
162
192
|
let runFirst = first;
|
|
163
193
|
let runOperators = [];
|
|
@@ -166,22 +196,22 @@ function fold(first, operators, segments, context, detail) {
|
|
|
166
196
|
const relations = [];
|
|
167
197
|
for (let index = 0; index < operators.length; index += 1) {
|
|
168
198
|
const operator = operators[index];
|
|
169
|
-
const
|
|
170
|
-
if (operator === void 0 ||
|
|
171
|
-
if (
|
|
199
|
+
const segment = segments[index];
|
|
200
|
+
if (operator === void 0 || segment === void 0) throw new Error("operator and segment lists diverged while folding a lowered sequence");
|
|
201
|
+
if (segment.nodes.length === 0) {
|
|
172
202
|
diagnose(context, "latex/operator-placement-unparsed", detail);
|
|
173
203
|
return unparsed(detail);
|
|
174
204
|
}
|
|
175
205
|
if (RELATION_OPERATORS.has(operator)) {
|
|
176
206
|
operands.push(foldArithmetic(runFirst, runOperators, runSegments, context));
|
|
177
207
|
relations.push(operator);
|
|
178
|
-
runFirst =
|
|
208
|
+
runFirst = lowerFoldSegment(segment, context);
|
|
179
209
|
runOperators = [];
|
|
180
210
|
runSegments = [];
|
|
181
211
|
continue;
|
|
182
212
|
}
|
|
183
213
|
runOperators.push(operator);
|
|
184
|
-
runSegments.push(
|
|
214
|
+
runSegments.push(segment);
|
|
185
215
|
}
|
|
186
216
|
operands.push(foldArithmetic(runFirst, runOperators, runSegments, context));
|
|
187
217
|
let folded = operands[0];
|
|
@@ -198,12 +228,16 @@ function foldArithmetic(first, operators, segments, context) {
|
|
|
198
228
|
let folded = first;
|
|
199
229
|
for (let index = 0; index < operators.length; index += 1) {
|
|
200
230
|
const operator = operators[index];
|
|
201
|
-
const
|
|
202
|
-
if (operator === void 0 ||
|
|
203
|
-
folded = app(operator, [folded,
|
|
231
|
+
const segment = segments[index];
|
|
232
|
+
if (operator === void 0 || segment === void 0) throw new Error("operator and segment lists diverged while folding an arithmetic run");
|
|
233
|
+
folded = app(operator, [folded, lowerFoldSegment(segment, context)]);
|
|
204
234
|
}
|
|
205
235
|
return folded;
|
|
206
236
|
}
|
|
237
|
+
function lowerFoldSegment(segment, context) {
|
|
238
|
+
const folded = lowerTerm(segment.nodes, context);
|
|
239
|
+
return segment.negated ? app(UNARY_MINUS_OPERATOR, [folded]) : folded;
|
|
240
|
+
}
|
|
207
241
|
function lowerTerm(nodes, context) {
|
|
208
242
|
return lowerTermItems(termItems(nodes), context);
|
|
209
243
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "js.documents",
|
|
3
|
-
"version": "7.17.
|
|
3
|
+
"version": "7.17.5",
|
|
4
4
|
"description": "Bidirectional docx/pptx <-> PDF conversion and a read+write editable OOXML document model, built on ooxml.js and Zod 4 codecs.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"repository": {
|
|
@@ -77,21 +77,21 @@
|
|
|
77
77
|
],
|
|
78
78
|
"license": "MIT",
|
|
79
79
|
"dependencies": {
|
|
80
|
-
"archive-codec": "1.10.
|
|
81
|
-
"byte-codec": "1.4.
|
|
82
|
-
"doc-codec": "2.
|
|
83
|
-
"document-schema.js": "7.6.
|
|
84
|
-
"epub-codec": "1.3.
|
|
80
|
+
"archive-codec": "1.10.3",
|
|
81
|
+
"byte-codec": "1.4.2",
|
|
82
|
+
"doc-codec": "2.8.1",
|
|
83
|
+
"document-schema.js": "7.6.1",
|
|
84
|
+
"epub-codec": "1.3.5",
|
|
85
85
|
"fflate": "0.8.3",
|
|
86
|
-
"markdown-codec": "6.6.
|
|
87
|
-
"odf.js": "7.23.
|
|
88
|
-
"ooxml.js": "8.
|
|
89
|
-
"pdf-codec": "4.5.
|
|
90
|
-
"ppt-codec": "1.4.
|
|
91
|
-
"rtf-codec": "4.1
|
|
86
|
+
"markdown-codec": "6.6.2",
|
|
87
|
+
"odf.js": "7.23.2",
|
|
88
|
+
"ooxml.js": "8.10.1",
|
|
89
|
+
"pdf-codec": "4.5.2",
|
|
90
|
+
"ppt-codec": "1.4.6",
|
|
91
|
+
"rtf-codec": "4.2.1",
|
|
92
92
|
"temml": "0.13.4",
|
|
93
|
-
"wpd-codec": "3.4.
|
|
94
|
-
"xls-codec": "4.12.
|
|
93
|
+
"wpd-codec": "3.4.1",
|
|
94
|
+
"xls-codec": "4.12.2",
|
|
95
95
|
"zod": "4.4.3"
|
|
96
96
|
},
|
|
97
97
|
"devDependencies": {
|