@adobe/helix-importer 2.5.7 → 2.5.10

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,24 @@
1
+ ## [2.5.10](https://github.com/adobe/helix-importer/compare/v2.5.9...v2.5.10) (2023-01-19)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * trigger releae ([d64999b](https://github.com/adobe/helix-importer/commit/d64999badb29281d1b2e2c14705af16dcbd78cbb))
7
+
8
+ ## [2.5.9](https://github.com/adobe/helix-importer/compare/v2.5.8...v2.5.9) (2023-01-19)
9
+
10
+
11
+ ### Bug Fixes
12
+
13
+ * Simplify underline handler ([0aa1b14](https://github.com/adobe/helix-importer/commit/0aa1b1434404fb6cf157f8ad548a627492b44e6b))
14
+
15
+ ## [2.5.8](https://github.com/adobe/helix-importer/compare/v2.5.7...v2.5.8) (2023-01-19)
16
+
17
+
18
+ ### Bug Fixes
19
+
20
+ * **deps:** update dependency hast-util-to-mdast to v9 ([#68](https://github.com/adobe/helix-importer/issues/68)) ([e09dcd1](https://github.com/adobe/helix-importer/commit/e09dcd1498c852cacf6403e562934fc79bba5093))
21
+
1
22
  ## [2.5.7](https://github.com/adobe/helix-importer/compare/v2.5.6...v2.5.7) (2023-01-19)
2
23
 
3
24
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adobe/helix-importer",
3
- "version": "2.5.7",
3
+ "version": "2.5.10",
4
4
  "description": "Helix Importer tool: create md / docx from html",
5
5
  "main": "src/index.js",
6
6
  "type": "module",
@@ -52,12 +52,11 @@
52
52
  "@adobe/remark-gridtables": "1.0.1",
53
53
  "form-data": "4.0.0",
54
54
  "fs-extra": "11.1.0",
55
- "hast-util-to-html": "8.0.4",
56
- "hast-util-to-mdast": "8.4.1",
55
+ "hast-util-to-mdast": "9.0.0",
57
56
  "jsdom": "21.0.0",
58
57
  "node-fetch": "3.3.0",
59
58
  "rehype-parse": "8.0.4",
60
- "rehype-remark": "9.1.2",
59
+ "rehype-remark": "github:adobe-rnd/rehype-remark#45735e80a3d3c805d3c4211ae035f718ddd10bcb",
61
60
  "remark-stringify": "10.0.2",
62
61
  "unified": "10.1.2"
63
62
  }
@@ -17,7 +17,6 @@ import { JSDOM } from 'jsdom';
17
17
  import path from 'path';
18
18
  import { unified } from 'unified';
19
19
  import parse from 'rehype-parse';
20
- import { toHtml } from 'hast-util-to-html';
21
20
  import rehype2remark from 'rehype-remark';
22
21
  import stringify from 'remark-stringify';
23
22
  import fs from 'fs-extra';
@@ -66,25 +65,17 @@ export default class PageImporter {
66
65
  .use(parse, { emitParseErrors: true })
67
66
  .use(rehype2remark, {
68
67
  handlers: {
69
- hlxembed: (h, node) => {
70
- const children = node.children.map((child) => processor.stringify(child).trim());
71
- return h(node, 'paragraph', [h(node, 'text', children.join())]);
72
- },
73
- u: (h, node) => {
68
+ u: (state, node) => {
74
69
  if (node.children && node.children.length > 0) {
75
- const children = node.children.map((child) => {
76
- try {
77
- if (child.type === 'element' && child.tagName !== 'span') {
78
- const n = h(child, child.tagName, child.children);
79
- return processor.stringify(n).trim();
80
- }
81
- return processor.stringify(child).trim();
82
- } catch (e) {
83
- // cannot stringify the node, return html
84
- return toHtml(child);
85
- }
86
- });
87
- return h(node, 'html', `<u>${children.join()}</u>`);
70
+ return [{
71
+ type: 'html',
72
+ value: '<u>',
73
+ },
74
+ ...state.all(node),
75
+ {
76
+ type: 'html',
77
+ value: '</u>',
78
+ }];
88
79
  }
89
80
  return '';
90
81
  },
@@ -9,7 +9,6 @@
9
9
  * OF ANY KIND, either express or implied. See the License for the specific language
10
10
  * governing permissions and limitations under the License.
11
11
  */
12
- import { all } from 'hast-util-to-mdast';
13
12
  import {
14
13
  TYPE_BODY,
15
14
  TYPE_CELL,
@@ -20,11 +19,11 @@ import {
20
19
  } from '@adobe/mdast-util-gridtables';
21
20
 
22
21
  function convert(type) {
23
- return (h, node) => h(node, type, all(h, node));
22
+ return (state, node) => ({ type, children: state.all(node) });
24
23
  }
25
24
 
26
- function table(h, node) {
27
- let children = all(h, node);
25
+ function table(state, node) {
26
+ let children = state.all(node);
28
27
 
29
28
  // people never create <thead> or <tbody>, but only use a <th> to mark the cell (row) as header
30
29
  // which is technically wrong, since also a column can be a header. however the default sanitized
@@ -52,22 +51,33 @@ function table(h, node) {
52
51
  }
53
52
  children = [];
54
53
  if (head.length) {
55
- children.push(h(node, TYPE_HEADER, head));
54
+ children.push({
55
+ type: TYPE_HEADER,
56
+ children: head,
57
+ });
56
58
  }
57
59
  if (body.length) {
58
- children.push(h(node, TYPE_BODY, body));
60
+ children.push({
61
+ type: TYPE_BODY,
62
+ children: body,
63
+ });
59
64
  }
60
65
  }
61
- return h(node, TYPE_TABLE, children);
66
+ return {
67
+ type: TYPE_TABLE,
68
+ children,
69
+ };
62
70
  }
63
71
 
64
- function row(h, node) {
65
- const mdast = h(node, TYPE_ROW, all(h, node));
66
- mdast.hasHeaderCell = node.hasHeaderCell;
67
- return mdast;
72
+ function row(state, node) {
73
+ return {
74
+ type: TYPE_ROW,
75
+ children: state.all(node),
76
+ hasHeaderCell: node.hasHeaderCell,
77
+ };
68
78
  }
69
79
 
70
- function cell(h, node, parent) {
80
+ function cell(state, node, parent) {
71
81
  const ATTR_MAP = {
72
82
  align: 'align',
73
83
  valign: 'valign',
@@ -87,7 +97,11 @@ function cell(h, node, parent) {
87
97
  }
88
98
  }
89
99
  }
90
- return h(node, TYPE_CELL, props, all(h, node));
100
+ return {
101
+ type: TYPE_CELL,
102
+ children: state.all(node),
103
+ ...props,
104
+ };
91
105
  }
92
106
 
93
107
  export default {
@@ -4,6 +4,5 @@
4
4
  <p><a href="http://wwww.sample.com/a">Link on a single online</a></p>
5
5
  <a href="http://wwww.sample.com/b">Link without p</a>
6
6
  <p>http://wwww.sample.com/c</p>
7
- <hlxembed>http://wwww.sample.com/d</hlxembed>
8
7
  </body>
9
8
  </html>
@@ -4,6 +4,4 @@
4
4
 
5
5
  [Link without p](http://wwww.sample.com/b)
6
6
 
7
- http://wwww.sample.com/c
8
-
9
- http://wwww.sample.com/d
7
+ http://wwww.sample.com/c
@@ -8,13 +8,16 @@ Some normal text with random <u>underline</u> or <u>span with underline</u> or <
8
8
 
9
9
  **<u>Underline 3</u>**
10
10
 
11
- - <u>li underline 1</u>
12
-
13
- - <u>li underline 2</u>
14
-
11
+ - <u>
12
+ li underline 1
13
+ </u>
14
+ - <u>
15
+ li underline 2
16
+ </u>
15
17
  also may have text here
16
-
17
- - <u>li underline 3</u>
18
+ - <u>
19
+ li underline 3
20
+ </u>
18
21
 
19
22
  [Unlined link](https:/www.sample.com/a) or [<u>Linked underline</u>](https:/www.sample.com/b) ?
20
23
 
@@ -22,4 +25,4 @@ Some normal text with random <u>underline</u> or <u>span with underline</u> or <
22
25
 
23
26
  [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
27
 
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)
28
+ [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)