@adobe/helix-md2jcr 1.1.12 → 1.1.14
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
CHANGED
|
@@ -1,3 +1,17 @@
|
|
|
1
|
+
## [1.1.14](https://github.com/adobe/helix-md2jcr/compare/v1.1.13...v1.1.14) (2025-04-24)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Bug Fixes
|
|
5
|
+
|
|
6
|
+
* support parsing links in blocks ([d391736](https://github.com/adobe/helix-md2jcr/commit/d3917369ce248c35e30ed36231eb4b15bb893a13))
|
|
7
|
+
|
|
8
|
+
## [1.1.13](https://github.com/adobe/helix-md2jcr/compare/v1.1.12...v1.1.13) (2025-04-15)
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
### Bug Fixes
|
|
12
|
+
|
|
13
|
+
* **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))
|
|
14
|
+
|
|
1
15
|
## [1.1.12](https://github.com/adobe/helix-md2jcr/compare/v1.1.11...v1.1.12) (2025-04-10)
|
|
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.14",
|
|
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.
|
|
58
|
+
"@adobe/helix-mediahandler": "2.7.0",
|
|
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
|
/**
|
|
@@ -106,8 +107,9 @@ function collapseField(id, fields, node, parentNode, properties) {
|
|
|
106
107
|
properties[field.name] = link.getType(parentNode);
|
|
107
108
|
}
|
|
108
109
|
} else if (link.supports(node)) {
|
|
109
|
-
if (suffix === 'Text') {
|
|
110
|
-
|
|
110
|
+
if (suffix === 'Text' || suffix === 'Title') {
|
|
111
|
+
const value = link.getProperties(node)[suffix.toLowerCase()];
|
|
112
|
+
properties[field.name] = encodeHTMLEntities(value);
|
|
111
113
|
} else {
|
|
112
114
|
properties[field.name] = encodeHTMLEntities(node[suffix.toLowerCase()]);
|
|
113
115
|
}
|
|
@@ -188,16 +190,41 @@ function extractKeyValueProperties(row, model, fieldResolver, fieldGroup, proper
|
|
|
188
190
|
}
|
|
189
191
|
}
|
|
190
192
|
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
193
|
+
function processCell(cell, fieldGroup, fieldResolver, properties) {
|
|
194
|
+
const cellChildren = cell.children;
|
|
195
|
+
if (cellChildren.length !== 0) {
|
|
196
|
+
while (cellChildren.length > 0) {
|
|
197
|
+
const node = cellChildren.shift();
|
|
198
|
+
const field = fieldResolver.resolve(node, fieldGroup);
|
|
199
|
+
let pWrapper;
|
|
200
|
+
if (field.component === 'richtext') {
|
|
201
|
+
pWrapper = {
|
|
202
|
+
type: 'wrapper',
|
|
203
|
+
children: [node],
|
|
204
|
+
};
|
|
205
|
+
|
|
206
|
+
let searching = true;
|
|
207
|
+
|
|
208
|
+
while (searching) {
|
|
209
|
+
const n = cellChildren.shift();
|
|
210
|
+
if (!n) break;
|
|
211
|
+
|
|
212
|
+
if (find(n, { type: 'image' })) {
|
|
213
|
+
cellChildren.unshift(n);
|
|
214
|
+
searching = false;
|
|
215
|
+
}
|
|
216
|
+
if (searching) {
|
|
217
|
+
pWrapper.children.push(n);
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
} else {
|
|
221
|
+
pWrapper = node;
|
|
222
|
+
}
|
|
223
|
+
extractPropertiesForNode(field, pWrapper, properties);
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
|
|
201
228
|
function extractProperties(mdast, model, mode, component, fields, properties) {
|
|
202
229
|
const fieldsCloned = structuredClone(fields);
|
|
203
230
|
|
|
@@ -251,57 +278,11 @@ function extractProperties(mdast, model, mode, component, fields, properties) {
|
|
|
251
278
|
if (mode === 'keyValue') {
|
|
252
279
|
extractKeyValueProperties(row, model, fieldResolver, fieldGroup, properties);
|
|
253
280
|
} else {
|
|
254
|
-
// for each cell in the row, process the nodes that exist in the cell
|
|
255
|
-
let processing = false;
|
|
256
281
|
for (const cell of cells) {
|
|
257
|
-
if (mode === 'blockItem'
|
|
282
|
+
if (mode === 'blockItem') {
|
|
258
283
|
fieldGroup = fieldsCloned.shift();
|
|
259
284
|
}
|
|
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
|
-
}
|
|
285
|
+
processCell(cell, fieldGroup, fieldResolver, properties, mode);
|
|
305
286
|
}
|
|
306
287
|
}
|
|
307
288
|
}
|
|
@@ -377,15 +358,8 @@ function getBlockItems(mdast, modelHelper, definitions, allowedComponents) {
|
|
|
377
358
|
};
|
|
378
359
|
|
|
379
360
|
extractProperties(row, fieldGroup.model, 'blockItem', component, fieldGroup.fields, properties);
|
|
380
|
-
|
|
381
361
|
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
362
|
}
|
|
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
363
|
}
|
|
390
364
|
});
|
|
391
365
|
|