@adobe/helix-importer 2.5.7 → 2.5.8
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
|
+
## [2.5.8](https://github.com/adobe/helix-importer/compare/v2.5.7...v2.5.8) (2023-01-19)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Bug Fixes
|
|
5
|
+
|
|
6
|
+
* **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))
|
|
7
|
+
|
|
1
8
|
## [2.5.7](https://github.com/adobe/helix-importer/compare/v2.5.6...v2.5.7) (2023-01-19)
|
|
2
9
|
|
|
3
10
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@adobe/helix-importer",
|
|
3
|
-
"version": "2.5.
|
|
3
|
+
"version": "2.5.8",
|
|
4
4
|
"description": "Helix Importer tool: create md / docx from html",
|
|
5
5
|
"main": "src/index.js",
|
|
6
6
|
"type": "module",
|
|
@@ -53,11 +53,11 @@
|
|
|
53
53
|
"form-data": "4.0.0",
|
|
54
54
|
"fs-extra": "11.1.0",
|
|
55
55
|
"hast-util-to-html": "8.0.4",
|
|
56
|
-
"hast-util-to-mdast": "
|
|
56
|
+
"hast-util-to-mdast": "9.0.0",
|
|
57
57
|
"jsdom": "21.0.0",
|
|
58
58
|
"node-fetch": "3.3.0",
|
|
59
59
|
"rehype-parse": "8.0.4",
|
|
60
|
-
"rehype-remark": "
|
|
60
|
+
"rehype-remark": "github:adobe-rnd/rehype-remark#45735e80a3d3c805d3c4211ae035f718ddd10bcb",
|
|
61
61
|
"remark-stringify": "10.0.2",
|
|
62
62
|
"unified": "10.1.2"
|
|
63
63
|
}
|
|
@@ -66,16 +66,25 @@ export default class PageImporter {
|
|
|
66
66
|
.use(parse, { emitParseErrors: true })
|
|
67
67
|
.use(rehype2remark, {
|
|
68
68
|
handlers: {
|
|
69
|
-
hlxembed: (
|
|
69
|
+
hlxembed: (state, node) => {
|
|
70
70
|
const children = node.children.map((child) => processor.stringify(child).trim());
|
|
71
|
-
return
|
|
71
|
+
return {
|
|
72
|
+
type: 'paragraph',
|
|
73
|
+
children: [{
|
|
74
|
+
type: 'text',
|
|
75
|
+
value: children.join(''),
|
|
76
|
+
}],
|
|
77
|
+
};
|
|
72
78
|
},
|
|
73
|
-
u: (
|
|
79
|
+
u: (state, node) => {
|
|
74
80
|
if (node.children && node.children.length > 0) {
|
|
75
81
|
const children = node.children.map((child) => {
|
|
76
82
|
try {
|
|
77
83
|
if (child.type === 'element' && child.tagName !== 'span') {
|
|
78
|
-
const n =
|
|
84
|
+
const n = {
|
|
85
|
+
type: child.tagName,
|
|
86
|
+
children: child.children,
|
|
87
|
+
};
|
|
79
88
|
return processor.stringify(n).trim();
|
|
80
89
|
}
|
|
81
90
|
return processor.stringify(child).trim();
|
|
@@ -84,7 +93,20 @@ export default class PageImporter {
|
|
|
84
93
|
return toHtml(child);
|
|
85
94
|
}
|
|
86
95
|
});
|
|
87
|
-
return
|
|
96
|
+
return {
|
|
97
|
+
type: 'html',
|
|
98
|
+
value: `<u>${children.join('')}</u>`,
|
|
99
|
+
};
|
|
100
|
+
// todo: use this
|
|
101
|
+
// return [{
|
|
102
|
+
// type: 'html',
|
|
103
|
+
// value: '<u>',
|
|
104
|
+
// },
|
|
105
|
+
// ...state.all(node),
|
|
106
|
+
// {
|
|
107
|
+
// type: 'html',
|
|
108
|
+
// value: '</u>',
|
|
109
|
+
// }];
|
|
88
110
|
}
|
|
89
111
|
return '';
|
|
90
112
|
},
|
|
@@ -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 (
|
|
22
|
+
return (state, node) => ({ type, children: state.all(node) });
|
|
24
23
|
}
|
|
25
24
|
|
|
26
|
-
function table(
|
|
27
|
-
let children = all(
|
|
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(
|
|
54
|
+
children.push({
|
|
55
|
+
type: TYPE_HEADER,
|
|
56
|
+
children: head,
|
|
57
|
+
});
|
|
56
58
|
}
|
|
57
59
|
if (body.length) {
|
|
58
|
-
children.push(
|
|
60
|
+
children.push({
|
|
61
|
+
type: TYPE_BODY,
|
|
62
|
+
children: body,
|
|
63
|
+
});
|
|
59
64
|
}
|
|
60
65
|
}
|
|
61
|
-
return
|
|
66
|
+
return {
|
|
67
|
+
type: TYPE_TABLE,
|
|
68
|
+
children,
|
|
69
|
+
};
|
|
62
70
|
}
|
|
63
71
|
|
|
64
|
-
function row(
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
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(
|
|
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
|
|
100
|
+
return {
|
|
101
|
+
type: TYPE_CELL,
|
|
102
|
+
children: state.all(node),
|
|
103
|
+
...props,
|
|
104
|
+
};
|
|
91
105
|
}
|
|
92
106
|
|
|
93
107
|
export default {
|
|
@@ -147,6 +147,7 @@ describe('PageImporter tests - fixtures', () => {
|
|
|
147
147
|
|
|
148
148
|
const md = await storageHandler.get(results[0].md);
|
|
149
149
|
const expectedMD = await fs.readFile(path.resolve(__dirname, 'fixtures', `${feature}.spec.md`), 'utf-8');
|
|
150
|
+
console.log(md);
|
|
150
151
|
strictEqual(md.trim(), expectedMD.trim(), 'imported md is expected one');
|
|
151
152
|
};
|
|
152
153
|
|
|
@@ -9,11 +9,8 @@ Some normal text with random <u>underline</u> or <u>span with underline</u> or <
|
|
|
9
9
|
**<u>Underline 3</u>**
|
|
10
10
|
|
|
11
11
|
- <u>li underline 1</u>
|
|
12
|
-
|
|
13
12
|
- <u>li underline 2</u>
|
|
14
|
-
|
|
15
13
|
also may have text here
|
|
16
|
-
|
|
17
14
|
- <u>li underline 3</u>
|
|
18
15
|
|
|
19
16
|
[Unlined link](https:/www.sample.com/a) or [<u>Linked underline</u>](https:/www.sample.com/b) ?
|
|
@@ -22,4 +19,4 @@ Some normal text with random <u>underline</u> or <u>span with underline</u> or <
|
|
|
22
19
|
|
|
23
20
|
[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
21
|
|
|
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)
|
|
22
|
+
[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)
|