@adobe/helix-importer 1.1.0 → 1.2.2
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 +21 -0
- package/package.json +30 -14
- package/src/importer/PageImporter.js +23 -23
- package/src/index.js +4 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,24 @@
|
|
|
1
|
+
## [1.2.2](https://github.com/adobe/helix-importer/compare/v1.2.1...v1.2.2) (2022-01-25)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Bug Fixes
|
|
5
|
+
|
|
6
|
+
* update md2docx ([#13](https://github.com/adobe/helix-importer/issues/13)) ([cf3f48f](https://github.com/adobe/helix-importer/commit/cf3f48f2dec1190dda03d9f97c0c41b8e212999a))
|
|
7
|
+
|
|
8
|
+
## [1.2.1](https://github.com/adobe/helix-importer/compare/v1.2.0...v1.2.1) (2022-01-25)
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
### Bug Fixes
|
|
12
|
+
|
|
13
|
+
* export MemoryHandler ([#12](https://github.com/adobe/helix-importer/issues/12)) ([3a83a16](https://github.com/adobe/helix-importer/commit/3a83a1620b0eb4752698ee9b994e8b0fd7ce085f))
|
|
14
|
+
|
|
15
|
+
# [1.2.0](https://github.com/adobe/helix-importer/compare/v1.1.0...v1.2.0) (2022-01-20)
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
### Features
|
|
19
|
+
|
|
20
|
+
* export new Blocks helper ([#7](https://github.com/adobe/helix-importer/issues/7)) ([0d7bfa7](https://github.com/adobe/helix-importer/commit/0d7bfa7bd7a98a6fb19f6aec6f8e29be0549e53e))
|
|
21
|
+
|
|
1
22
|
# [1.1.0](https://github.com/adobe/helix-importer/compare/v1.0.0...v1.1.0) (2022-01-20)
|
|
2
23
|
|
|
3
24
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@adobe/helix-importer",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.2.2",
|
|
4
4
|
"description": "Helix Importer tool: create md / docx from html",
|
|
5
5
|
"main": "src/index.js",
|
|
6
6
|
"type": "module",
|
|
@@ -10,37 +10,53 @@
|
|
|
10
10
|
},
|
|
11
11
|
"scripts": {
|
|
12
12
|
"lint": "eslint .",
|
|
13
|
-
"test": "mocha
|
|
14
|
-
"
|
|
13
|
+
"test": "c8 mocha",
|
|
14
|
+
"test-ci": "c8 mocha && codecov",
|
|
15
|
+
"semantic-release": "semantic-release",
|
|
16
|
+
"prepare": "npx husky install"
|
|
17
|
+
},
|
|
18
|
+
"mocha": {
|
|
19
|
+
"recursive": "true",
|
|
20
|
+
"spec": "test/**/*.spec.js",
|
|
21
|
+
"reporter": "mocha-multi-reporters",
|
|
22
|
+
"reporter-options": "configFile=.mocha-multi.json"
|
|
23
|
+
},
|
|
24
|
+
"lint-staged": {
|
|
25
|
+
"*.js": "eslint"
|
|
15
26
|
},
|
|
16
27
|
"devDependencies": {
|
|
17
28
|
"@adobe/eslint-config-helix": "1.3.2",
|
|
18
|
-
"@adobe/helix-docx2md": "1.0.
|
|
19
|
-
"@adobe/helix-mediahandler": "1.0.
|
|
29
|
+
"@adobe/helix-docx2md": "1.0.6",
|
|
30
|
+
"@adobe/helix-mediahandler": "1.0.2",
|
|
20
31
|
"@semantic-release/changelog": "6.0.1",
|
|
21
32
|
"@semantic-release/exec": "6.0.3",
|
|
22
33
|
"@semantic-release/git": "10.0.1",
|
|
23
|
-
"
|
|
34
|
+
"c8": "7.11.0",
|
|
35
|
+
"codecov": "3.8.3",
|
|
36
|
+
"eslint": "8.7.0",
|
|
24
37
|
"eslint-plugin-header": "3.1.1",
|
|
25
38
|
"eslint-plugin-import": "2.25.4",
|
|
26
|
-
"
|
|
27
|
-
"
|
|
39
|
+
"husky": "7.0.4",
|
|
40
|
+
"lint-staged": "12.3.1",
|
|
41
|
+
"mocha": "9.2.0",
|
|
42
|
+
"mocha-multi-reporters": "1.5.1",
|
|
43
|
+
"mock-fs": "5.1.2",
|
|
28
44
|
"semantic-release": "19.0.2"
|
|
29
45
|
},
|
|
30
46
|
"author": "",
|
|
31
47
|
"license": "Apache-2.0",
|
|
32
48
|
"dependencies": {
|
|
33
|
-
"@adobe/helix-md2docx": "1.2.
|
|
49
|
+
"@adobe/helix-md2docx": "1.2.3",
|
|
34
50
|
"form-data": "4.0.0",
|
|
35
51
|
"fs-extra": "10.0.0",
|
|
36
52
|
"hast-util-to-html": "8.0.3",
|
|
37
53
|
"hast-util-to-mdast": "8.3.0",
|
|
38
54
|
"jsdom": "19.0.0",
|
|
39
|
-
"node-fetch": "3.
|
|
40
|
-
"rehype-parse": "
|
|
41
|
-
"rehype-remark": "
|
|
42
|
-
"remark-stringify": "
|
|
55
|
+
"node-fetch": "3.2.0",
|
|
56
|
+
"rehype-parse": "8.0.3",
|
|
57
|
+
"rehype-remark": "9.1.2",
|
|
58
|
+
"remark-stringify": "10.0.2",
|
|
43
59
|
"sanitize-filename": "1.6.3",
|
|
44
|
-
"unified": "
|
|
60
|
+
"unified": "10.1.1"
|
|
45
61
|
}
|
|
46
62
|
}
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
import { JSDOM } from 'jsdom';
|
|
16
16
|
|
|
17
17
|
import path from 'path';
|
|
18
|
-
import unified from 'unified';
|
|
18
|
+
import { unified } from 'unified';
|
|
19
19
|
import parse from 'rehype-parse';
|
|
20
20
|
import { toHtml } from 'hast-util-to-html';
|
|
21
21
|
import rehype2remark from 'rehype-remark';
|
|
@@ -50,7 +50,7 @@ export default class PageImporter {
|
|
|
50
50
|
const { name } = resource;
|
|
51
51
|
const { directory } = resource;
|
|
52
52
|
const sanitizedName = FileUtils.sanitizeFilename(name);
|
|
53
|
-
this.logger.log(`Computing
|
|
53
|
+
this.logger.log(`Computing Markdown for ${directory}/${sanitizedName}`);
|
|
54
54
|
|
|
55
55
|
const processor = unified()
|
|
56
56
|
.use(parse, { emitParseErrors: true })
|
|
@@ -73,36 +73,36 @@ export default class PageImporter {
|
|
|
73
73
|
.use(() => {
|
|
74
74
|
// use custom tag and rendering because text is always encoded by default
|
|
75
75
|
// we need the raw url
|
|
76
|
-
processor.Compiler.prototype.visitors.hlxembed = (node) => node.value;
|
|
76
|
+
// processor.Compiler.prototype.visitors.hlxembed = (node) => node.value;
|
|
77
77
|
})
|
|
78
78
|
.use(() => {
|
|
79
|
-
processor.Compiler.prototype.visitors.table = (node) => node.value;
|
|
79
|
+
// processor.Compiler.prototype.visitors.table = (node) => node.value;
|
|
80
80
|
})
|
|
81
81
|
.use(() => {
|
|
82
|
-
processor.Compiler.prototype.visitors.u = (node) => {
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
};
|
|
82
|
+
// processor.Compiler.prototype.visitors.u = (node) => {
|
|
83
|
+
// // u handling: remove the u is the first element is a link
|
|
84
|
+
// if (node.children && node.children.length > 0) {
|
|
85
|
+
// const children = node.children.map((child) => processor.stringify(child));
|
|
86
|
+
// if (node.children[0].type === 'link') {
|
|
87
|
+
// // first element in the <u> is a link: remove the <u> - unsupported case
|
|
88
|
+
// return `${children.join()}`;
|
|
89
|
+
// }
|
|
90
|
+
// return `<u>${children.join()}</u>`;
|
|
91
|
+
// }
|
|
92
|
+
// return '';
|
|
93
|
+
// };
|
|
94
94
|
})
|
|
95
95
|
.use(() => {
|
|
96
|
-
const originalEmphasis = processor.Compiler.prototype.visitors.emphasis;
|
|
97
|
-
processor.Compiler.prototype.visitors.emphasis = (node) => {
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
};
|
|
96
|
+
// const originalEmphasis = processor.Compiler.prototype.visitors.emphasis;
|
|
97
|
+
// processor.Compiler.prototype.visitors.emphasis = (node) => {
|
|
98
|
+
// // @ts-ignore
|
|
99
|
+
// const ori = originalEmphasis.apply(processor.Compiler(), [node]);
|
|
100
|
+
// return ori;
|
|
101
|
+
// };
|
|
102
102
|
});
|
|
103
103
|
|
|
104
104
|
const file = await processor.process(resource.document.innerHTML);
|
|
105
|
-
let contents = file
|
|
105
|
+
let contents = String(file);
|
|
106
106
|
|
|
107
107
|
// process image links
|
|
108
108
|
const { document } = resource;
|
package/src/index.js
CHANGED
|
@@ -17,7 +17,9 @@ import PageImporterParams from './importer/PageImporterParams.js';
|
|
|
17
17
|
import PageImporterResource from './importer/PageImporterResource.js';
|
|
18
18
|
|
|
19
19
|
import FSHandler from './storage/FSHandler.js';
|
|
20
|
+
import MemoryHandler from './storage/MemoryHandler.js';
|
|
20
21
|
|
|
22
|
+
import Blocks from './utils/Blocks.js';
|
|
21
23
|
import CSV from './utils/CSV.js';
|
|
22
24
|
import DOMUtils from './utils/DOMUtils.js';
|
|
23
25
|
import FileUtils from './utils/FileUtils.js';
|
|
@@ -35,6 +37,8 @@ export {
|
|
|
35
37
|
PageImporterParams,
|
|
36
38
|
PageImporterResource,
|
|
37
39
|
FSHandler,
|
|
40
|
+
MemoryHandler,
|
|
41
|
+
Blocks,
|
|
38
42
|
CSV,
|
|
39
43
|
DOMUtils,
|
|
40
44
|
FileUtils,
|