@adobe/helix-md2jcr 1.1.32 → 1.1.33

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,10 @@
1
+ ## [1.1.33](https://github.com/adobe/helix-md2jcr/compare/v1.1.32...v1.1.33) (2025-09-03)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * container blocks fail to parse correctly when no class is provided ([#147](https://github.com/adobe/helix-md2jcr/issues/147)) ([846f281](https://github.com/adobe/helix-md2jcr/commit/846f281509f47ddeb228a6cda9d6252e42861b74))
7
+
1
8
  ## [1.1.32](https://github.com/adobe/helix-md2jcr/compare/v1.1.31...v1.1.32) (2025-08-27)
2
9
 
3
10
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adobe/helix-md2jcr",
3
- "version": "1.1.32",
3
+ "version": "1.1.33",
4
4
  "description": "Helix Service that converts markdown to JCR content structure",
5
5
  "main": "src/index.js",
6
6
  "type": "module",
@@ -55,14 +55,14 @@
55
55
  },
56
56
  "devDependencies": {
57
57
  "@adobe/eslint-config-helix": "3.0.9",
58
- "@adobe/helix-mediahandler": "2.8.1",
58
+ "@adobe/helix-mediahandler": "2.8.2",
59
59
  "@commitlint/cli": "^19.6.1",
60
60
  "@commitlint/config-conventional": "^19.6.0",
61
61
  "@semantic-release/changelog": "6.0.3",
62
62
  "@semantic-release/exec": "7.1.0",
63
63
  "@semantic-release/git": "10.0.1",
64
64
  "c8": "10.1.3",
65
- "chai": "^5.2.0",
65
+ "chai": "^6.0.0",
66
66
  "dotenv": "17.2.1",
67
67
  "eslint": "^9.0.0",
68
68
  "eslint-import-resolver-exports": "1.0.0-beta.5",
@@ -70,8 +70,8 @@
70
70
  "eslint-plugin-import": "2.32.0",
71
71
  "husky": "^9.1.7",
72
72
  "junit-report-builder": "5.1.1",
73
- "lint-staged": "16.1.5",
74
- "mocha": "11.7.1",
73
+ "lint-staged": "16.1.6",
74
+ "mocha": "11.7.2",
75
75
  "mocha-multi-reporters": "1.5.1",
76
76
  "nock": "13.5.6",
77
77
  "semantic-release": "24.2.7",
@@ -263,11 +263,30 @@ function processCell(cell, fieldGroup, fieldResolver, properties) {
263
263
  }
264
264
  }
265
265
 
266
- function extractProperties(mdast, model, mode, component, fields, properties) {
266
+ /**
267
+ * Extract the properties for the block item.
268
+ * @param {*} mdast - The mdast tree.
269
+ * @param {*} model - The model.
270
+ * @param {*} mode - The mode, either 'blockItem' or 'keyValue' or 'simple'.
271
+ * @param {*} component - The component.
272
+ * @param {*} fields - The fields.
273
+ * @param {*} properties - The properties.
274
+ * @param {*} skipFirstCell - Use to tell the function to skip the first cell when
275
+ * processing the block item. This is only applicable when mode is 'blockItem' and
276
+ * when there is a component id specified in the first cell of the row for the block item.
277
+ */
278
+ function extractProperties(
279
+ mdast,
280
+ model,
281
+ mode,
282
+ component,
283
+ fields,
284
+ properties,
285
+ skipFirstCell,
286
+ ) {
267
287
  const fieldsCloned = structuredClone(fields);
268
288
 
269
289
  // the first cells is the header row, so we skip it
270
- // const nodes = findAll(mdast, (node) => node.type === 'gtCell', true);
271
290
  const rows = findAll(mdast, (node) => node.type === 'gtRow', false);
272
291
  let classesField;
273
292
  if (mode === 'blockItem') {
@@ -314,7 +333,7 @@ function extractProperties(mdast, model, mode, component, fields, properties) {
314
333
  // We then want to throw away the first cell as it is the class field
315
334
  // EC currently does not add the classes field therefore more cells than model fields
316
335
  // See container-block.md for an example of more cells than model fields (second table)
317
- if (mode === 'blockItem' && classesField && (cells.length > modelFields.length)) {
336
+ if (mode === 'blockItem' && (skipFirstCell) && (cells.length > modelFields.length)) {
318
337
  cells.shift();
319
338
  }
320
339
 
@@ -382,12 +401,14 @@ function getBlockItems(mdast, modelHelper, definitions, allowedComponents) {
382
401
 
383
402
  // the first cell may be defined as the component id (with optional classes)
384
403
  let componentId = cellText.split(',').shift().trim();
385
-
404
+ let skipFirstCell = false;
386
405
  // if we can't find the component id in the allowed components it means
387
406
  // the user has not specified what component to use therefore we fall back
388
407
  // to the first allowed component.
389
408
  if (allowedComponents.indexOf(componentId) === -1) {
390
409
  [componentId] = allowedComponents;
410
+ } else {
411
+ skipFirstCell = true;
391
412
  }
392
413
 
393
414
  // check to see if we can use this component
@@ -400,7 +421,7 @@ function getBlockItems(mdast, modelHelper, definitions, allowedComponents) {
400
421
  modelFields: `[${getModelFieldNames(fieldGroup.model).join(',')}]`,
401
422
  };
402
423
 
403
- extractProperties(row, fieldGroup.model, 'blockItem', component, fieldGroup.fields, properties);
424
+ extractProperties(row, fieldGroup.model, 'blockItem', component, fieldGroup.fields, properties, skipFirstCell);
404
425
  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}>`);
405
426
  }
406
427
  }