@adobe/helix-md2jcr 1.0.16 → 1.1.0

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.0](https://github.com/adobe/helix-md2jcr/compare/v1.0.16...v1.1.0) (2025-02-25)
2
+
3
+
4
+ ### Features
5
+
6
+ * **sites-29456:** support eds markdown ([#59](https://github.com/adobe/helix-md2jcr/issues/59)) ([400565a](https://github.com/adobe/helix-md2jcr/commit/400565af9096c8c549fd48b59f1a9ac58e9ec2f9))
7
+
1
8
  ## [1.0.16](https://github.com/adobe/helix-md2jcr/compare/v1.0.15...v1.0.16) (2025-02-25)
2
9
 
3
10
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adobe/helix-md2jcr",
3
- "version": "1.0.16",
3
+ "version": "1.1.0",
4
4
  "description": "Helix Service that converts markdown to JCR content structure",
5
5
  "main": "src/index.js",
6
6
  "type": "module",
@@ -29,6 +29,7 @@ import gridTablePartial from './hb/partials/grid-table.js';
29
29
  import pageHelper from './hb/helpers/page-helper.js';
30
30
  import pageTemplate from './templates/page-template.js';
31
31
  import unsupportedPartial from './hb/partials/unsupported.js';
32
+ import sanitizeEds from './mdast-sanitize-eds.js';
32
33
 
33
34
  /**
34
35
  * Converts a markdown AST to JCR XML. This function is the main entry point
@@ -40,6 +41,7 @@ import unsupportedPartial from './hb/partials/unsupported.js';
40
41
  * @returns {Promise<string>}
41
42
  */
42
43
  export default async function mdast2jcr(mdast, options = {}) {
44
+ mdast = sanitizeEds(mdast);
43
45
  mdast = sanitizeHtml(mdast);
44
46
  mdast = splitSection(mdast);
45
47
  mdast = unwrapElements(mdast);
@@ -0,0 +1,39 @@
1
+ /*
2
+ * Copyright 2025 Adobe. All rights reserved.
3
+ * This file is licensed to you under the Apache License, Version 2.0 (the "License");
4
+ * you may not use this file except in compliance with the License. You may obtain a copy
5
+ * of the License at http://www.apache.org/licenses/LICENSE-2.0
6
+ *
7
+ * Unless required by applicable law or agreed to in writing, software distributed under
8
+ * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
9
+ * OF ANY KIND, either express or implied. See the License for the specific language
10
+ * governing permissions and limitations under the License.
11
+ */
12
+ import { visit } from 'unist-util-visit';
13
+
14
+ export default function sanitizeEds(tree) {
15
+ visit(tree, 'gridTable', (gridTableNode) => {
16
+ const hasHeader = gridTableNode.children.some((child) => child.type === 'gtHeader');
17
+ if (!hasHeader) {
18
+ const firstBodyIndex = gridTableNode.children.findIndex(
19
+ (child) => child.type === 'gtBody',
20
+ );
21
+ if (firstBodyIndex !== -1) {
22
+ const firstBody = gridTableNode.children[firstBodyIndex];
23
+ if (firstBody.children && firstBody.children.length > 0) {
24
+ const [firstRow] = firstBody.children.splice(0, 1);
25
+
26
+ const newHeader = {
27
+ type: 'gtHeader',
28
+ children: [firstRow],
29
+ position: firstRow.position,
30
+ };
31
+
32
+ gridTableNode.children.splice(firstBodyIndex, 0, newHeader);
33
+ }
34
+ }
35
+ }
36
+ });
37
+
38
+ return tree;
39
+ }