@adobe/helix-importer 3.4.41 → 3.4.43
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 +14 -0
- package/package.json +6 -5
- package/src/importer/HTML2x.js +18 -1
- package/src/importer/PageImporter.js +13 -0
- package/src/index.js +2 -1
- package/test/importers/PageImporter.spec.js +1 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,17 @@
|
|
|
1
|
+
## [3.4.43](https://github.com/adobe/helix-importer/compare/v3.4.42...v3.4.43) (2025-01-28)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Bug Fixes
|
|
5
|
+
|
|
6
|
+
* **deps:** update dependency @adobe/helix-md2jcr to v1.0.4 ([#474](https://github.com/adobe/helix-importer/issues/474)) ([7ee88ee](https://github.com/adobe/helix-importer/commit/7ee88ee2891b3e69db6ba149a3dd008921f46204))
|
|
7
|
+
|
|
8
|
+
## [3.4.42](https://github.com/adobe/helix-importer/compare/v3.4.41...v3.4.42) (2025-01-28)
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
### Bug Fixes
|
|
12
|
+
|
|
13
|
+
* **deps:** update dependency @adobe/helix-md2docx to v2.1.99 ([#472](https://github.com/adobe/helix-importer/issues/472)) ([a3ee8d6](https://github.com/adobe/helix-importer/commit/a3ee8d600e7cd3453ba65522863074e91e692b64))
|
|
14
|
+
|
|
1
15
|
## [3.4.41](https://github.com/adobe/helix-importer/compare/v3.4.40...v3.4.41) (2025-01-26)
|
|
2
16
|
|
|
3
17
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@adobe/helix-importer",
|
|
3
|
-
"version": "3.4.
|
|
3
|
+
"version": "3.4.43",
|
|
4
4
|
"description": "Helix Importer tool: create md / docx from html",
|
|
5
5
|
"main": "src/index.js",
|
|
6
6
|
"type": "module",
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
"devDependencies": {
|
|
29
29
|
"@adobe/eslint-config-helix": "2.0.8",
|
|
30
30
|
"@adobe/helix-docx2md": "1.6.15",
|
|
31
|
-
"@adobe/helix-mediahandler": "2.5.
|
|
31
|
+
"@adobe/helix-mediahandler": "2.5.48",
|
|
32
32
|
"@esm-bundle/chai": "4.3.4-fix.0",
|
|
33
33
|
"@semantic-release/changelog": "6.0.3",
|
|
34
34
|
"@semantic-release/exec": "6.0.3",
|
|
@@ -42,8 +42,8 @@
|
|
|
42
42
|
"eslint": "8.57.1",
|
|
43
43
|
"husky": "9.1.7",
|
|
44
44
|
"jsdom": "26.0.0",
|
|
45
|
-
"lint-staged": "15.4.
|
|
46
|
-
"mocha": "11.0
|
|
45
|
+
"lint-staged": "15.4.3",
|
|
46
|
+
"mocha": "11.1.0",
|
|
47
47
|
"mocha-multi-reporters": "1.5.1",
|
|
48
48
|
"mock-fs": "5.4.1",
|
|
49
49
|
"remark-parse": "11.0.0",
|
|
@@ -53,7 +53,8 @@
|
|
|
53
53
|
"license": "Apache-2.0",
|
|
54
54
|
"dependencies": {
|
|
55
55
|
"@adobe/helix-markdown-support": "7.1.10",
|
|
56
|
-
"@adobe/helix-md2docx": "2.1.
|
|
56
|
+
"@adobe/helix-md2docx": "2.1.99",
|
|
57
|
+
"@adobe/helix-md2jcr": "1.0.4",
|
|
57
58
|
"@adobe/mdast-util-gridtables": "4.0.9",
|
|
58
59
|
"@adobe/remark-gridtables": "3.0.9",
|
|
59
60
|
"form-data": "4.0.1",
|
package/src/importer/HTML2x.js
CHANGED
|
@@ -41,7 +41,7 @@ async function html2x(
|
|
|
41
41
|
url,
|
|
42
42
|
doc,
|
|
43
43
|
transformCfg,
|
|
44
|
-
config = { toMd: true, toDocx: false },
|
|
44
|
+
config = { toMd: true, toDocx: false, toJcr: false },
|
|
45
45
|
params = {},
|
|
46
46
|
) {
|
|
47
47
|
const transformer = transformCfg || {};
|
|
@@ -156,12 +156,14 @@ async function html2x(
|
|
|
156
156
|
storageHandler,
|
|
157
157
|
skipDocxConversion: !config.toDocx,
|
|
158
158
|
skipMDFileCreation: !config.toMd,
|
|
159
|
+
skipJcrFileCreation: !config.toJcr,
|
|
159
160
|
logger,
|
|
160
161
|
mdast2docxOptions: {
|
|
161
162
|
stylesXML: config.docxStylesXML,
|
|
162
163
|
image2png: config.image2png,
|
|
163
164
|
},
|
|
164
165
|
createDocumentFromString: config.createDocumentFromString,
|
|
166
|
+
components: params.components,
|
|
165
167
|
});
|
|
166
168
|
|
|
167
169
|
const pirs = await importer.import(url);
|
|
@@ -191,6 +193,10 @@ async function html2x(
|
|
|
191
193
|
const docx = await storageHandler.get(pir.docx);
|
|
192
194
|
res.docx = docx;
|
|
193
195
|
}
|
|
196
|
+
if (config.toJcr && pir.jcr) {
|
|
197
|
+
const jcr = await storageHandler.get(pir.jcr);
|
|
198
|
+
res.jcr = jcr;
|
|
199
|
+
}
|
|
194
200
|
return res;
|
|
195
201
|
};
|
|
196
202
|
|
|
@@ -247,7 +253,18 @@ async function html2docx(url, document, transformCfg, config, params = {}) {
|
|
|
247
253
|
return html2x(url, doc, transformCfg, { ...config, toMd: true, toDocx: true }, params);
|
|
248
254
|
}
|
|
249
255
|
|
|
256
|
+
async function md2jcr(url, document, transformCfg, config, params = {}) {
|
|
257
|
+
let doc = document;
|
|
258
|
+
if (typeof doc === 'string') {
|
|
259
|
+
doc = parseStringDocument(document, config);
|
|
260
|
+
}
|
|
261
|
+
return html2x(url, doc, transformCfg, {
|
|
262
|
+
...config, toMd: true, toDocx: false, toJcr: true,
|
|
263
|
+
}, params);
|
|
264
|
+
}
|
|
265
|
+
|
|
250
266
|
export {
|
|
267
|
+
md2jcr,
|
|
251
268
|
html2md,
|
|
252
269
|
html2docx,
|
|
253
270
|
defaultTransformDOM,
|
|
@@ -19,6 +19,7 @@ import { defaultHandlers, toMdast } from 'hast-util-to-mdast';
|
|
|
19
19
|
import stringify from 'remark-stringify';
|
|
20
20
|
import fs from 'fs-extra';
|
|
21
21
|
import { md2docx } from '@adobe/helix-md2docx';
|
|
22
|
+
import { md2jcr } from '@adobe/helix-md2jcr';
|
|
22
23
|
import remarkGridTable from '@adobe/remark-gridtables';
|
|
23
24
|
import {
|
|
24
25
|
imageReferences,
|
|
@@ -73,6 +74,11 @@ export default class PageImporter {
|
|
|
73
74
|
return this.params.storageHandler.put(docxPath, buffer);
|
|
74
75
|
}
|
|
75
76
|
|
|
77
|
+
async convertToJcr(jcrPath, content) {
|
|
78
|
+
const buffer = await md2jcr(content, this.params.components);
|
|
79
|
+
return this.params.storageHandler.put(jcrPath, buffer);
|
|
80
|
+
}
|
|
81
|
+
|
|
76
82
|
async createMarkdown(resource, url) {
|
|
77
83
|
const { name } = resource;
|
|
78
84
|
const { directory } = resource;
|
|
@@ -358,6 +364,13 @@ export default class PageImporter {
|
|
|
358
364
|
// eslint-disable-next-line no-param-reassign
|
|
359
365
|
entry.docx = docxPath;
|
|
360
366
|
}
|
|
367
|
+
|
|
368
|
+
if (!this.params.skipJcrFileCreation) {
|
|
369
|
+
const jcrPath = `${res.path}.xml`;
|
|
370
|
+
await this.convertToJcr(jcrPath, res.content);
|
|
371
|
+
// eslint-disable-next-line no-param-reassign
|
|
372
|
+
entry.jcr = jcrPath;
|
|
373
|
+
}
|
|
361
374
|
}
|
|
362
375
|
|
|
363
376
|
results.push(entry);
|
package/src/index.js
CHANGED
|
@@ -25,7 +25,7 @@ import Utils from './utils/Utils.js';
|
|
|
25
25
|
|
|
26
26
|
import WPUtils from './wp/WPUtils.js';
|
|
27
27
|
|
|
28
|
-
import { html2md, html2docx } from './importer/HTML2x.js';
|
|
28
|
+
import { html2md, html2docx, md2jcr } from './importer/HTML2x.js';
|
|
29
29
|
|
|
30
30
|
import createMetadata from './importer/defaults/rules/createMetadata.js';
|
|
31
31
|
import adjustImageUrls from './importer/defaults/rules/adjustImageUrls.js';
|
|
@@ -54,5 +54,6 @@ export {
|
|
|
54
54
|
WPUtils,
|
|
55
55
|
html2md,
|
|
56
56
|
html2docx,
|
|
57
|
+
md2jcr,
|
|
57
58
|
rules,
|
|
58
59
|
};
|