@adobe/helix-md2jcr 1.1.11 → 1.1.13
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/CHANGELOG.md +14 -0
- package/baseline-tests.sh +32 -9
- package/package.json +4 -4
- package/src/mdast2jcr/hb/partials/grid-table.js +39 -66
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,17 @@
|
|
|
1
|
+
## [1.1.13](https://github.com/adobe/helix-md2jcr/compare/v1.1.12...v1.1.13) (2025-04-15)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Bug Fixes
|
|
5
|
+
|
|
6
|
+
* **sites-30804:** container blocks throw error with empty cell ([#82](https://github.com/adobe/helix-md2jcr/issues/82)) ([abbd3c2](https://github.com/adobe/helix-md2jcr/commit/abbd3c28a44990e29e08f242e13954f14fb63bbe))
|
|
7
|
+
|
|
8
|
+
## [1.1.12](https://github.com/adobe/helix-md2jcr/compare/v1.1.11...v1.1.12) (2025-04-10)
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
### Bug Fixes
|
|
12
|
+
|
|
13
|
+
* missing required primary type on block items ([#81](https://github.com/adobe/helix-md2jcr/issues/81)) ([e5d2139](https://github.com/adobe/helix-md2jcr/commit/e5d2139620fa00d76a4a051250e4c7eb9e0949a7))
|
|
14
|
+
|
|
1
15
|
## [1.1.11](https://github.com/adobe/helix-md2jcr/compare/v1.1.10...v1.1.11) (2025-04-07)
|
|
2
16
|
|
|
3
17
|
|
package/baseline-tests.sh
CHANGED
|
@@ -2,14 +2,15 @@
|
|
|
2
2
|
|
|
3
3
|
# create a function that prints the usage of the script
|
|
4
4
|
usage() {
|
|
5
|
-
echo "Usage: $0 [-v] [-d]"
|
|
5
|
+
echo "Usage: $0 [-v] [-d] [-f file]"
|
|
6
6
|
echo " -v: Verbose mode"
|
|
7
7
|
echo " -d: Decode output mode"
|
|
8
|
+
echo " -f: Specify a single file to process"
|
|
8
9
|
exit 1
|
|
9
10
|
}
|
|
10
11
|
|
|
11
|
-
# verify that the command arguments are only -v or -
|
|
12
|
-
while getopts ":
|
|
12
|
+
# verify that the command arguments are only -v, -d, or -f if any other commands are found exit with an error
|
|
13
|
+
while getopts ":vdf:" opt; do
|
|
13
14
|
case ${opt} in
|
|
14
15
|
v )
|
|
15
16
|
VERBOSE="true"
|
|
@@ -17,6 +18,9 @@ while getopts ":vd" opt; do
|
|
|
17
18
|
d )
|
|
18
19
|
DECODE="true"
|
|
19
20
|
;;
|
|
21
|
+
f )
|
|
22
|
+
SPECIFIC_FILE="$OPTARG"
|
|
23
|
+
;;
|
|
20
24
|
\? )
|
|
21
25
|
echo "Invalid option: $OPTARG" 1>&2
|
|
22
26
|
usage
|
|
@@ -28,7 +32,6 @@ while getopts ":vd" opt; do
|
|
|
28
32
|
esac
|
|
29
33
|
done
|
|
30
34
|
|
|
31
|
-
|
|
32
35
|
# Set the root directory to search for .md files
|
|
33
36
|
MD_DIR="test/fixtures"
|
|
34
37
|
|
|
@@ -41,6 +44,31 @@ if [ ! -d "$MD_DIR" ]; then
|
|
|
41
44
|
exit 1
|
|
42
45
|
fi
|
|
43
46
|
|
|
47
|
+
ARGS=""
|
|
48
|
+
[ "$VERBOSE" = "true" ] && ARGS="$ARGS -v"
|
|
49
|
+
[ "$DECODE" = "true" ] && ARGS="$ARGS -d"
|
|
50
|
+
|
|
51
|
+
# If a specific file is provided, process only that file
|
|
52
|
+
if [ -n "$SPECIFIC_FILE" ]; then
|
|
53
|
+
if [ ! -f "$SPECIFIC_FILE" ]; then
|
|
54
|
+
echo "File $SPECIFIC_FILE does not exist."
|
|
55
|
+
exit 1
|
|
56
|
+
fi
|
|
57
|
+
|
|
58
|
+
echo "Processing $SPECIFIC_FILE..."
|
|
59
|
+
[ "$VERBOSE" = "true" ] && echo
|
|
60
|
+
|
|
61
|
+
node "$NODE_SCRIPT" "$SPECIFIC_FILE" $ARGS 2>/dev/null
|
|
62
|
+
|
|
63
|
+
if [ $? -ne 0 ]; then
|
|
64
|
+
echo "Error processing $SPECIFIC_FILE with $NODE_SCRIPT."
|
|
65
|
+
exit 1
|
|
66
|
+
fi
|
|
67
|
+
|
|
68
|
+
echo "File processed successfully."
|
|
69
|
+
exit 0
|
|
70
|
+
fi
|
|
71
|
+
|
|
44
72
|
# Find all .md files recursively in the directory
|
|
45
73
|
MD_FILES=$(find "$MD_DIR" -type f -name "*.md")
|
|
46
74
|
|
|
@@ -50,10 +78,6 @@ if [ -z "$MD_FILES" ]; then
|
|
|
50
78
|
exit 1
|
|
51
79
|
fi
|
|
52
80
|
|
|
53
|
-
ARGS=""
|
|
54
|
-
[ "$VERBOSE" = "true" ] && ARGS="$ARGS -v"
|
|
55
|
-
[ "$DECODE" = "true" ] && ARGS="$ARGS -d"
|
|
56
|
-
|
|
57
81
|
# Iterate over each .md file
|
|
58
82
|
for MD_FILE in $MD_FILES; do
|
|
59
83
|
# if VERBOSE is true then echo a new line
|
|
@@ -74,5 +98,4 @@ for MD_FILE in $MD_FILES; do
|
|
|
74
98
|
fi
|
|
75
99
|
done
|
|
76
100
|
|
|
77
|
-
|
|
78
101
|
echo "All .md files have been processed successfully."
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@adobe/helix-md2jcr",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.13",
|
|
4
4
|
"description": "Helix Service that converts markdown to JCR content structure",
|
|
5
5
|
"main": "src/index.js",
|
|
6
6
|
"type": "module",
|
|
@@ -55,7 +55,7 @@
|
|
|
55
55
|
},
|
|
56
56
|
"devDependencies": {
|
|
57
57
|
"@adobe/eslint-config-helix": "2.0.9",
|
|
58
|
-
"@adobe/helix-mediahandler": "2.6.
|
|
58
|
+
"@adobe/helix-mediahandler": "2.6.12",
|
|
59
59
|
"@commitlint/cli": "^19.6.1",
|
|
60
60
|
"@commitlint/config-conventional": "^19.6.0",
|
|
61
61
|
"@semantic-release/changelog": "6.0.3",
|
|
@@ -63,14 +63,14 @@
|
|
|
63
63
|
"@semantic-release/git": "10.0.1",
|
|
64
64
|
"c8": "10.1.3",
|
|
65
65
|
"chai": "^5.2.0",
|
|
66
|
-
"dotenv": "16.
|
|
66
|
+
"dotenv": "16.5.0",
|
|
67
67
|
"eslint": "8.57.1",
|
|
68
68
|
"eslint-import-resolver-exports": "1.0.0-beta.5",
|
|
69
69
|
"eslint-plugin-header": "3.1.1",
|
|
70
70
|
"eslint-plugin-import": "2.31.0",
|
|
71
71
|
"husky": "^9.1.7",
|
|
72
72
|
"junit-report-builder": "5.1.1",
|
|
73
|
-
"lint-staged": "15.5.
|
|
73
|
+
"lint-staged": "15.5.1",
|
|
74
74
|
"mocha": "10.8.2",
|
|
75
75
|
"mocha-multi-reporters": "1.5.1",
|
|
76
76
|
"nock": "13.5.6",
|
|
@@ -34,6 +34,7 @@ import ModelHelper from '../../domain/ModelHelper.js';
|
|
|
34
34
|
/**
|
|
35
35
|
* @typedef {import('../../index.d.ts').FieldDef} Field
|
|
36
36
|
* @typedef {import('../../index.d.ts').DefinitionDef} Definition
|
|
37
|
+
* @typedef {import('../../index.d.ts').Filter} Filters
|
|
37
38
|
*/
|
|
38
39
|
|
|
39
40
|
/**
|
|
@@ -188,16 +189,41 @@ function extractKeyValueProperties(row, model, fieldResolver, fieldGroup, proper
|
|
|
188
189
|
}
|
|
189
190
|
}
|
|
190
191
|
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
192
|
+
function processCell(cell, fieldGroup, fieldResolver, properties) {
|
|
193
|
+
const cellChildren = cell.children;
|
|
194
|
+
if (cellChildren.length !== 0) {
|
|
195
|
+
while (cellChildren.length > 0) {
|
|
196
|
+
const node = cellChildren.shift();
|
|
197
|
+
const field = fieldResolver.resolve(node, fieldGroup);
|
|
198
|
+
let pWrapper;
|
|
199
|
+
if (field.component === 'richtext') {
|
|
200
|
+
pWrapper = {
|
|
201
|
+
type: 'wrapper',
|
|
202
|
+
children: [node],
|
|
203
|
+
};
|
|
204
|
+
|
|
205
|
+
let searching = true;
|
|
206
|
+
|
|
207
|
+
while (searching) {
|
|
208
|
+
const n = cellChildren.shift();
|
|
209
|
+
if (!n) break;
|
|
210
|
+
|
|
211
|
+
if (find(n, { type: 'image' })) {
|
|
212
|
+
cellChildren.unshift(n);
|
|
213
|
+
searching = false;
|
|
214
|
+
}
|
|
215
|
+
if (searching) {
|
|
216
|
+
pWrapper.children.push(n);
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
} else {
|
|
220
|
+
pWrapper = node;
|
|
221
|
+
}
|
|
222
|
+
extractPropertiesForNode(field, pWrapper, properties);
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
|
|
201
227
|
function extractProperties(mdast, model, mode, component, fields, properties) {
|
|
202
228
|
const fieldsCloned = structuredClone(fields);
|
|
203
229
|
|
|
@@ -251,57 +277,11 @@ function extractProperties(mdast, model, mode, component, fields, properties) {
|
|
|
251
277
|
if (mode === 'keyValue') {
|
|
252
278
|
extractKeyValueProperties(row, model, fieldResolver, fieldGroup, properties);
|
|
253
279
|
} else {
|
|
254
|
-
// for each cell in the row, process the nodes that exist in the cell
|
|
255
|
-
let processing = false;
|
|
256
280
|
for (const cell of cells) {
|
|
257
|
-
if (mode === 'blockItem'
|
|
281
|
+
if (mode === 'blockItem') {
|
|
258
282
|
fieldGroup = fieldsCloned.shift();
|
|
259
283
|
}
|
|
260
|
-
|
|
261
|
-
const nodes = cell.children;
|
|
262
|
-
if (nodes.length === 0) {
|
|
263
|
-
// throw away the field that was associated with the cell
|
|
264
|
-
fieldGroup.fields.shift();
|
|
265
|
-
processing = true;
|
|
266
|
-
// if there are no nodes in the cell, then we need to skip it
|
|
267
|
-
} else {
|
|
268
|
-
while (nodes.length > 0) {
|
|
269
|
-
const node = nodes.shift();
|
|
270
|
-
|
|
271
|
-
// give the field group (all fields to the resolver)
|
|
272
|
-
if (fieldGroup === undefined) {
|
|
273
|
-
console.warn(`No field group for ${model.id}`);
|
|
274
|
-
return;
|
|
275
|
-
}
|
|
276
|
-
|
|
277
|
-
const field = fieldResolver.resolve(node, fieldGroup);
|
|
278
|
-
let pWrapper;
|
|
279
|
-
if (field.component === 'richtext') {
|
|
280
|
-
pWrapper = {
|
|
281
|
-
type: 'wrapper',
|
|
282
|
-
children: [node],
|
|
283
|
-
};
|
|
284
|
-
|
|
285
|
-
let searching = true;
|
|
286
|
-
|
|
287
|
-
while (searching) {
|
|
288
|
-
const n = nodes.shift();
|
|
289
|
-
if (!n) break;
|
|
290
|
-
|
|
291
|
-
if (find(n, { type: 'image' })) {
|
|
292
|
-
nodes.unshift(n);
|
|
293
|
-
searching = false;
|
|
294
|
-
}
|
|
295
|
-
if (searching) {
|
|
296
|
-
pWrapper.children.push(n);
|
|
297
|
-
}
|
|
298
|
-
}
|
|
299
|
-
} else {
|
|
300
|
-
pWrapper = node;
|
|
301
|
-
}
|
|
302
|
-
extractPropertiesForNode(field, pWrapper, properties);
|
|
303
|
-
}
|
|
304
|
-
}
|
|
284
|
+
processCell(cell, fieldGroup, fieldResolver, properties, mode);
|
|
305
285
|
}
|
|
306
286
|
}
|
|
307
287
|
}
|
|
@@ -377,15 +357,8 @@ function getBlockItems(mdast, modelHelper, definitions, allowedComponents) {
|
|
|
377
357
|
};
|
|
378
358
|
|
|
379
359
|
extractProperties(row, fieldGroup.model, 'blockItem', component, fieldGroup.fields, properties);
|
|
380
|
-
|
|
381
|
-
items.push(`<item_${items.length} sling:resourceType="core/franklin/components/block/v1/block/item" name="${fieldGroup.model.id}" ${Object.entries(properties).map(([k, v]) => `${k}="${v}"`).join(' ')}></item_${items.length}>`);
|
|
360
|
+
items.push(`<item_${items.length} jcr:primaryType="nt:unstructured" sling:resourceType="core/franklin/components/block/v1/block/item" name="${fieldGroup.model.id}" ${Object.entries(properties).map(([k, v]) => `${k}="${v}"`).join(' ')}></item_${items.length}>`);
|
|
382
361
|
}
|
|
383
|
-
} else {
|
|
384
|
-
// const msg = `The component '${componentId}' is not allowed in the block
|
|
385
|
-
// '${modelHelper.blockName}'. Modify the ${modelHelper.blockName} filters
|
|
386
|
-
// file to include the '${componentId}' component in the list of
|
|
387
|
-
// components.`;
|
|
388
|
-
// console.error(msg);
|
|
389
362
|
}
|
|
390
363
|
});
|
|
391
364
|
|