js.documents 6.2.0 → 6.2.1

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.
@@ -158,8 +158,13 @@ function operatorOfNode(node) {
158
158
  }
159
159
  if (node.type === "textord" && nodeText(node) === "/") return "math:divide";
160
160
  }
161
+ const RELATION_OPERATORS = new Set(Object.values(RELATION_ATOM_OPERATORS));
161
162
  function fold(first, operators, segments, context, detail) {
162
- let folded = first;
163
+ let runFirst = first;
164
+ let runOperators = [];
165
+ let runSegments = [];
166
+ const operands = [];
167
+ const relations = [];
163
168
  for (let index = 0; index < operators.length; index += 1) {
164
169
  const operator = operators[index];
165
170
  const segmentNodes = segments[index];
@@ -168,6 +173,34 @@ function fold(first, operators, segments, context, detail) {
168
173
  diagnose(context, "latex/operator-placement-unparsed", detail);
169
174
  return unparsed(detail);
170
175
  }
176
+ if (RELATION_OPERATORS.has(operator)) {
177
+ operands.push(foldArithmetic(runFirst, runOperators, runSegments, context));
178
+ relations.push(operator);
179
+ runFirst = lowerTerm(segmentNodes, context);
180
+ runOperators = [];
181
+ runSegments = [];
182
+ continue;
183
+ }
184
+ runOperators.push(operator);
185
+ runSegments.push(segmentNodes);
186
+ }
187
+ operands.push(foldArithmetic(runFirst, runOperators, runSegments, context));
188
+ let folded = operands[0];
189
+ if (folded === void 0) throw new Error("fold produced no operand for a non-empty operator list");
190
+ for (let index = 0; index < relations.length; index += 1) {
191
+ const relation = relations[index];
192
+ const operand = operands[index + 1];
193
+ if (relation === void 0 || operand === void 0) throw new Error("relation and operand lists diverged while folding a lowered sequence");
194
+ folded = app(relation, [folded, operand]);
195
+ }
196
+ return folded;
197
+ }
198
+ function foldArithmetic(first, operators, segments, context) {
199
+ let folded = first;
200
+ for (let index = 0; index < operators.length; index += 1) {
201
+ const operator = operators[index];
202
+ const segmentNodes = segments[index];
203
+ if (operator === void 0 || segmentNodes === void 0) throw new Error("operator and segment lists diverged while folding an arithmetic run");
171
204
  folded = app(operator, [folded, lowerTerm(segmentNodes, context)]);
172
205
  }
173
206
  return folded;
@@ -157,8 +157,13 @@ function operatorOfNode(node) {
157
157
  }
158
158
  if (node.type === "textord" && nodeText(node) === "/") return "math:divide";
159
159
  }
160
+ const RELATION_OPERATORS = new Set(Object.values(RELATION_ATOM_OPERATORS));
160
161
  function fold(first, operators, segments, context, detail) {
161
- let folded = first;
162
+ let runFirst = first;
163
+ let runOperators = [];
164
+ let runSegments = [];
165
+ const operands = [];
166
+ const relations = [];
162
167
  for (let index = 0; index < operators.length; index += 1) {
163
168
  const operator = operators[index];
164
169
  const segmentNodes = segments[index];
@@ -167,6 +172,34 @@ function fold(first, operators, segments, context, detail) {
167
172
  diagnose(context, "latex/operator-placement-unparsed", detail);
168
173
  return unparsed(detail);
169
174
  }
175
+ if (RELATION_OPERATORS.has(operator)) {
176
+ operands.push(foldArithmetic(runFirst, runOperators, runSegments, context));
177
+ relations.push(operator);
178
+ runFirst = lowerTerm(segmentNodes, context);
179
+ runOperators = [];
180
+ runSegments = [];
181
+ continue;
182
+ }
183
+ runOperators.push(operator);
184
+ runSegments.push(segmentNodes);
185
+ }
186
+ operands.push(foldArithmetic(runFirst, runOperators, runSegments, context));
187
+ let folded = operands[0];
188
+ if (folded === void 0) throw new Error("fold produced no operand for a non-empty operator list");
189
+ for (let index = 0; index < relations.length; index += 1) {
190
+ const relation = relations[index];
191
+ const operand = operands[index + 1];
192
+ if (relation === void 0 || operand === void 0) throw new Error("relation and operand lists diverged while folding a lowered sequence");
193
+ folded = app(relation, [folded, operand]);
194
+ }
195
+ return folded;
196
+ }
197
+ function foldArithmetic(first, operators, segments, context) {
198
+ let folded = first;
199
+ for (let index = 0; index < operators.length; index += 1) {
200
+ const operator = operators[index];
201
+ const segmentNodes = segments[index];
202
+ if (operator === void 0 || segmentNodes === void 0) throw new Error("operator and segment lists diverged while folding an arithmetic run");
170
203
  folded = app(operator, [folded, lowerTerm(segmentNodes, context)]);
171
204
  }
172
205
  return folded;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "js.documents",
3
- "version": "6.2.0",
3
+ "version": "6.2.1",
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": {
@@ -78,12 +78,12 @@
78
78
  "license": "MIT",
79
79
  "dependencies": {
80
80
  "byte-codec": "^1.2.0",
81
- "document-schema.js": "^5.3.0",
81
+ "document-schema.js": "^5.4.0",
82
82
  "fflate": "^0.8.3",
83
- "markdown-codec": "^6.1.2",
83
+ "markdown-codec": "^6.1.3",
84
84
  "odf.js": "^6.1.2",
85
- "ooxml.js": "^6.3.0",
86
- "pdf-codec": "^3.5.3",
85
+ "ooxml.js": "^6.3.1",
86
+ "pdf-codec": "^3.5.4",
87
87
  "temml": "0.13.4",
88
88
  "zod": "^4.4.3"
89
89
  },