@adobe/helix-importer 1.16.0 → 2.0.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,22 @@
1
+ # [2.0.0](https://github.com/adobe/helix-importer/compare/v1.16.1...v2.0.0) (2022-09-23)
2
+
3
+
4
+ ### Features
5
+
6
+ * upgrade to latest md2docx ([4a8a38c](https://github.com/adobe/helix-importer/commit/4a8a38cb3ef0ff0ca2489b12f6b801af1e84d85b))
7
+
8
+
9
+ ### BREAKING CHANGES
10
+
11
+ * svg2png was replaced with image2png
12
+
13
+ ## [1.16.1](https://github.com/adobe/helix-importer/compare/v1.16.0...v1.16.1) (2022-09-15)
14
+
15
+
16
+ ### Bug Fixes
17
+
18
+ * better u tag support ([#27](https://github.com/adobe/helix-importer/issues/27)) ([6ffb3a3](https://github.com/adobe/helix-importer/commit/6ffb3a3f6bc86194bcce88dd5bdff2059162af3c))
19
+
1
20
  # [1.16.0](https://github.com/adobe/helix-importer/compare/v1.15.0...v1.16.0) (2022-08-10)
2
21
 
3
22
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adobe/helix-importer",
3
- "version": "1.16.0",
3
+ "version": "2.0.0",
4
4
  "description": "Helix Importer tool: create md / docx from html",
5
5
  "main": "src/index.js",
6
6
  "type": "module",
@@ -11,7 +11,7 @@
11
11
  "scripts": {
12
12
  "lint": "eslint .",
13
13
  "test": "c8 mocha",
14
- "test-ci": "c8 mocha && codecov",
14
+ "test-ci": "c8 mocha",
15
15
  "semantic-release": "semantic-release",
16
16
  "prepare": "npx husky install"
17
17
  },
@@ -26,37 +26,35 @@
26
26
  },
27
27
  "devDependencies": {
28
28
  "@adobe/eslint-config-helix": "1.3.2",
29
- "@adobe/helix-docx2md": "1.0.6",
30
- "@adobe/helix-mediahandler": "1.0.2",
29
+ "@adobe/helix-docx2md": "1.1.1",
30
+ "@adobe/helix-mediahandler": "1.2.4",
31
31
  "@semantic-release/changelog": "6.0.1",
32
32
  "@semantic-release/exec": "6.0.3",
33
33
  "@semantic-release/git": "10.0.1",
34
- "c8": "7.11.0",
35
- "codecov": "3.8.3",
34
+ "c8": "7.12.0",
36
35
  "dirname-filename-esm": "1.1.1",
37
36
  "eslint": "8.7.0",
38
37
  "eslint-plugin-header": "3.1.1",
39
38
  "eslint-plugin-import": "2.25.4",
40
- "husky": "7.0.4",
41
- "lint-staged": "12.3.1",
42
- "mocha": "9.2.0",
39
+ "husky": "8.0.1",
40
+ "lint-staged": "13.0.3",
41
+ "mocha": "10.0.0",
43
42
  "mocha-multi-reporters": "1.5.1",
44
- "mock-fs": "5.1.2",
45
- "semantic-release": "19.0.2"
43
+ "mock-fs": "5.1.4",
44
+ "semantic-release": "19.0.5"
46
45
  },
47
- "author": "",
48
46
  "license": "Apache-2.0",
49
47
  "dependencies": {
50
- "@adobe/helix-md2docx": "1.4.3",
48
+ "@adobe/helix-md2docx": "2.0.1",
51
49
  "form-data": "4.0.0",
52
- "fs-extra": "10.0.0",
50
+ "fs-extra": "10.1.0",
53
51
  "hast-util-to-html": "8.0.3",
54
- "hast-util-to-mdast": "8.3.0",
55
- "jsdom": "19.0.0",
56
- "node-fetch": "3.2.0",
57
- "rehype-parse": "8.0.3",
52
+ "hast-util-to-mdast": "8.4.1",
53
+ "jsdom": "20.0.0",
54
+ "node-fetch": "3.2.10",
55
+ "rehype-parse": "8.0.4",
58
56
  "rehype-remark": "9.1.2",
59
57
  "remark-stringify": "10.0.2",
60
- "unified": "10.1.1"
58
+ "unified": "10.1.2"
61
59
  }
62
60
  }
@@ -159,7 +159,7 @@ async function html2x(
159
159
  logger,
160
160
  mdast2docxOptions: {
161
161
  stylesXML: config.docxStylesXML,
162
- svg2png: config.svg2png,
162
+ image2png: config.image2png,
163
163
  },
164
164
  });
165
165
 
@@ -65,7 +65,18 @@ export default class PageImporter {
65
65
  },
66
66
  u: (h, node) => {
67
67
  if (node.children && node.children.length > 0) {
68
- const children = node.children.map((child) => processor.stringify(child).trim());
68
+ const children = node.children.map((child) => {
69
+ try {
70
+ if (child.type === 'element' && child.tagName !== 'span') {
71
+ const n = h(child, child.tagName, child.children);
72
+ return processor.stringify(n).trim();
73
+ }
74
+ return processor.stringify(child).trim();
75
+ } catch (e) {
76
+ // cannot stringify the node, return html
77
+ return toHtml(child);
78
+ }
79
+ });
69
80
  return h(node, 'html', `<u>${children.join()}</u>`);
70
81
  }
71
82
  return '';
@@ -194,11 +205,13 @@ export default class PageImporter {
194
205
  ].forEach((tag) => DOMUtils.reviewInlineElement(document, tag));
195
206
 
196
207
  // u a tag combo is not handled properly by unified js and is discouraged anyway -> remove the u
197
- document.querySelectorAll('u > a').forEach((a) => {
198
- const p = a.parentNode;
199
- p.before(a);
200
- p.remove();
208
+ const us = [];
209
+ document.querySelectorAll('u > a, u > span > a').forEach((a) => {
210
+ const u = a.closest('u');
211
+ u.before(a);
212
+ us.push(u);
201
213
  });
214
+ us.forEach((u) => u.remove());
202
215
 
203
216
  const imgs = document.querySelectorAll('img');
204
217
  imgs.forEach((img) => {
@@ -13,5 +13,8 @@
13
13
  <p>
14
14
  <u><a href="https:/www.sample.com/a">Unlined link</a></u> or <a href="https:/www.sample.com/b"><u>Linked underline</u></a> ?
15
15
  </p>
16
+ <p><u><strong>Some underline and strong text</strong></u></p>
17
+ <p><u><a href="https://www.austinparks.org/" adhocenable="false">U and A are not friends</a>,&nbsp;<a href="http://www.bgcaustin.org/" adhocenable="false">Boys &amp; Girls Clubs of the Austin Area</a>,&nbsp;<a href="http://www.thefirstteeaustin.org/club/scripts/public/public.asp" adhocenable="false">The First Tee of Greater Austin</a>&nbsp;</u></p>
18
+ <p><u><span class="theme-color"><a href="https://www.austinparks.org/" adhocenable="false">U and A are not friends</a>,&nbsp;<a href="http://www.bgcaustin.org/" adhocenable="false">Boys &amp; Girls Clubs of the Austin Area</a>,&nbsp;<a href="http://www.thefirstteeaustin.org/club/scripts/public/public.asp" adhocenable="false">The First Tee of Greater Austin</a>&nbsp;</span></u></p>
16
19
  </body>
17
20
  </html>
@@ -16,4 +16,10 @@ Some normal text with random <u>underline</u> or <u>span with underline</u> or <
16
16
 
17
17
  - <u>li underline 3</u>
18
18
 
19
- [Unlined link](https:/www.sample.com/a) or [<u>Linked underline</u>](https:/www.sample.com/b) ?
19
+ [Unlined link](https:/www.sample.com/a) or [<u>Linked underline</u>](https:/www.sample.com/b) ?
20
+
21
+ <u>**Some underline and strong text**</u>
22
+
23
+ [U and A are not friends](https://www.austinparks.org/)[Boys & Girls Clubs of the Austin Area](http://www.bgcaustin.org/)[The First Tee of Greater Austin](http://www.thefirstteeaustin.org/club/scripts/public/public.asp)
24
+
25
+ [U and A are not friends](https://www.austinparks.org/)[Boys & Girls Clubs of the Austin Area](http://www.bgcaustin.org/)[The First Tee of Greater Austin](http://www.thefirstteeaustin.org/club/scripts/public/public.asp)