@gmb/bitmark-parser-generator 3.25.1 → 3.25.2
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/browser/bitmark-parser-generator.min.js +1 -1
- package/dist/browser/bundle-report.html +2 -2
- package/dist/cjs/generated/build-info.js +1 -1
- package/dist/cjs/generated/parser/text/text-peggy-parser.js +16 -14
- package/dist/cjs/generated/parser/text/text-peggy-parser.js.map +1 -1
- package/dist/esm/generated/build-info.js +1 -1
- package/dist/esm/generated/parser/text/text-peggy-parser.js +16 -14
- package/dist/esm/generated/parser/text/text-peggy-parser.js.map +1 -1
- package/dist/types/generated/parser/text/text-peggy-parser.d.ts.map +1 -1
- package/package.json +1 -1
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
//
|
|
3
3
|
// https://peggyjs.org/
|
|
4
4
|
import { Breakscape } from "../../../breakscaping/Breakscape";
|
|
5
|
-
const VERSION = "8.32.
|
|
5
|
+
const VERSION = "8.32.2";
|
|
6
6
|
//Parser peggy.js
|
|
7
7
|
// parser options (parameter when running parser):
|
|
8
8
|
// allowedStartRules: ["bitmarkPlusPlus", "bitmarkPlus", "bitmarkMinusMinus", "bitmarkPlusString", "bitmarkMinusMinusString"]
|
|
@@ -129,32 +129,34 @@ function removeTempParsingParent(obj) {
|
|
|
129
129
|
// }
|
|
130
130
|
// return node;
|
|
131
131
|
// }
|
|
132
|
+
/**
|
|
133
|
+
* RAS 2025-05-22
|
|
134
|
+
* Fixes / features
|
|
135
|
+
* - Handles arrays or objects as input (including root array) - main reason for change
|
|
136
|
+
* - Modifies in-place rather than copying array.
|
|
137
|
+
* - Removed some unnecessary checks - will work fine without them
|
|
138
|
+
*/
|
|
132
139
|
function cleanEmptyTextNodes(root) {
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
typeof n === "object" &&
|
|
136
|
-
n.type === "text" &&
|
|
137
|
-
(n.text === "" || n.text == null); // catches null & undefined
|
|
138
|
-
/** Recursively walk only through `content` arrays */
|
|
140
|
+
const isEmptyTextNode = (n) => n && n.type === "text" && !n.text;
|
|
141
|
+
// Recursively walk 'content' arrays
|
|
139
142
|
function cleanContentArray(arr) {
|
|
140
143
|
for (let i = arr.length - 1; i >= 0; i--) {
|
|
141
144
|
const item = arr[i];
|
|
142
145
|
if (isEmptyTextNode(item)) {
|
|
143
|
-
|
|
146
|
+
// drop the empty text node
|
|
147
|
+
arr.splice(i, 1);
|
|
144
148
|
}
|
|
145
|
-
else if (item &&
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
cleanContentArray(item.content); // recurse into nested `content`
|
|
149
|
+
else if (item && Array.isArray(item.content)) {
|
|
150
|
+
// recurse into `content` array
|
|
151
|
+
cleanContentArray(item.content);
|
|
149
152
|
}
|
|
150
153
|
// Any other shape is ignored.
|
|
151
154
|
}
|
|
152
155
|
}
|
|
153
|
-
// Kick-off: root may itself be an array or an object with `content`
|
|
154
156
|
if (Array.isArray(root)) {
|
|
155
157
|
cleanContentArray(root);
|
|
156
158
|
}
|
|
157
|
-
else if (root &&
|
|
159
|
+
else if (root && Array.isArray(root.content)) {
|
|
158
160
|
cleanContentArray(root.content);
|
|
159
161
|
}
|
|
160
162
|
return root;
|