@adobe/helix-md2docx 1.0.3 → 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 CHANGED
@@ -1,3 +1,31 @@
1
+ ## [1.2.2](https://github.com/adobe/helix-md2docx/compare/v1.2.1...v1.2.2) (2022-01-24)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * **deps:** update dependency @adobe/helix-docx2md to v1.0.6 ([#13](https://github.com/adobe/helix-md2docx/issues/13)) ([6ffcee4](https://github.com/adobe/helix-md2docx/commit/6ffcee4f5e5c3b2da6fd0625554dfeeb49b91525))
7
+
8
+ ## [1.2.1](https://github.com/adobe/helix-md2docx/compare/v1.2.0...v1.2.1) (2022-01-24)
9
+
10
+
11
+ ### Bug Fixes
12
+
13
+ * **deps:** update dependency @adobe/helix-markdown-support to v3.1.2 ([#12](https://github.com/adobe/helix-md2docx/issues/12)) ([6a95f1b](https://github.com/adobe/helix-md2docx/commit/6a95f1bca73db0814812cc03d33372887367eb7a))
14
+
15
+ # [1.2.0](https://github.com/adobe/helix-md2docx/compare/v1.1.0...v1.2.0) (2022-01-20)
16
+
17
+
18
+ ### Features
19
+
20
+ * move cli to get rid of the mediahanlder dep ([b7e8349](https://github.com/adobe/helix-md2docx/commit/b7e8349a0a2e0d06ad9f95b6287a3322e9bba9d9))
21
+
22
+ # [1.1.0](https://github.com/adobe/helix-md2docx/compare/v1.0.3...v1.1.0) (2022-01-19)
23
+
24
+
25
+ ### Features
26
+
27
+ * export md2docx ([42f7e88](https://github.com/adobe/helix-md2docx/commit/42f7e88aa55534a0f9bf3b7ef13a598c2d304003))
28
+
1
29
  ## [1.0.3](https://github.com/adobe/helix-md2docx/compare/v1.0.2...v1.0.3) (2022-01-19)
2
30
 
3
31
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adobe/helix-md2docx",
3
- "version": "1.0.3",
3
+ "version": "1.2.2",
4
4
  "description": "Helix Service that converts markdown to word documents",
5
5
  "main": "src/index.js",
6
6
  "type": "module",
@@ -28,13 +28,12 @@
28
28
  "homepage": "https://github.com/adobe/helix-md2docx#readme",
29
29
  "dependencies": {
30
30
  "@adobe/helix-fetch": "3.0.0",
31
- "@adobe/helix-markdown-support": "3.1.1",
31
+ "@adobe/helix-markdown-support": "3.1.2",
32
32
  "@adobe/helix-shared-process-queue": "1.1.0",
33
- "@adobe/helix-docx2md": "1.0.5",
34
- "@adobe/helix-mediahandler": "1.0.1",
33
+ "@adobe/helix-docx2md": "1.0.6",
35
34
  "dirname-filename-esm": "1.1.1",
36
35
  "docx": "7.3.0",
37
- "hast-util-is-element": "2.1.1",
36
+ "hast-util-is-element": "2.1.2",
38
37
  "hast-util-to-mdast": "8.3.0",
39
38
  "image-size": "1.0.1",
40
39
  "rehype-parse": "8.0.3",
@@ -45,21 +44,22 @@
45
44
  },
46
45
  "devDependencies": {
47
46
  "@adobe/eslint-config-helix": "1.3.2",
47
+ "@adobe/helix-mediahandler": "1.0.2",
48
48
  "@semantic-release/changelog": "6.0.1",
49
49
  "@semantic-release/exec": "6.0.3",
50
50
  "@semantic-release/git": "10.0.1",
51
51
  "c8": "7.11.0",
52
52
  "chai": "4.3.4",
53
53
  "codecov": "3.8.3",
54
- "dotenv": "14.1.0",
55
- "eslint": "8.6.0",
54
+ "dotenv": "14.2.0",
55
+ "eslint": "8.7.0",
56
56
  "eslint-plugin-header": "3.1.1",
57
57
  "eslint-plugin-import": "2.25.4",
58
58
  "fs-extra": "10.0.0",
59
59
  "husky": "7.0.4",
60
60
  "junit-report-builder": "3.0.0",
61
- "lint-staged": "12.1.7",
62
- "mocha": "9.1.3",
61
+ "lint-staged": "12.2.2",
62
+ "mocha": "9.1.4",
63
63
  "mocha-multi-reporters": "1.5.1",
64
64
  "semantic-release": "18.0.1",
65
65
  "unist-util-inspect": "7.0.0"
@@ -15,42 +15,8 @@ import {
15
15
  readdir, readFile, stat, writeFile,
16
16
  } from 'fs/promises';
17
17
  import path from 'path';
18
- import { unified } from 'unified';
19
- import remark from 'remark-parse';
20
- import gfm from 'remark-gfm';
21
- import { remarkMatter } from '@adobe/helix-markdown-support';
22
- import { MediaHandler } from '@adobe/helix-mediahandler';
23
18
  import { docx2md } from '@adobe/helix-docx2md';
24
- import { mdast2docx } from '../index.js';
25
-
26
- class MockMediaHandler extends MediaHandler {
27
- constructor(params) {
28
- super({
29
- owner: 'owner',
30
- repo: 'repo',
31
- ref: 'ref',
32
- contentBusId: 'dummyId',
33
- ...params,
34
- });
35
- }
36
-
37
- // eslint-disable-next-line class-methods-use-this
38
- async checkBlobExists() {
39
- return true;
40
- }
41
-
42
- // eslint-disable-next-line class-methods-use-this
43
- async getBlob(uri) {
44
- return {
45
- contentType: 'image/png',
46
- uri,
47
- meta: {
48
- width: '32',
49
- height: '32',
50
- },
51
- };
52
- }
53
- }
19
+ import { md2docx } from '../index.js';
54
20
 
55
21
  async function run(filePath) {
56
22
  // eslint-disable-next-line no-param-reassign
@@ -75,20 +41,12 @@ async function run(filePath) {
75
41
  console.log(`converting ${file} -> ${path.relative(process.cwd(), fileDocx)}`);
76
42
 
77
43
  const md = await readFile(file);
78
- const mdast = unified()
79
- .use(remark, { position: false })
80
- .use(gfm)
81
- .use(remarkMatter)
82
- .parse(md);
83
-
84
- const buffer = await mdast2docx(mdast);
44
+ const buffer = await md2docx(md);
85
45
  await writeFile(fileDocx, buffer);
86
46
 
87
47
  // convert back for verification
88
48
  console.log(`verifying ${path.relative(process.cwd(), fileDocx)} -> ${path.relative(process.cwd(), fileMD)}`);
89
- const newMD = await docx2md(buffer, {
90
- mediaHandler: new MockMediaHandler(),
91
- });
49
+ const newMD = await docx2md(buffer, {});
92
50
  await writeFile(fileMD, newMD, 'utf-8');
93
51
  }
94
52
  }
package/src/index.d.ts CHANGED
@@ -9,5 +9,8 @@
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
- // eslint-disable-next-line import/prefer-default-export
13
- export { default as mdast2docx } from './mdast2docx/index.js';
12
+
13
+ import mdast2docx from './mdast2docx/index.js';
14
+ import md2docx from './md2docx/index.js';
15
+
16
+ export { mdast2docx, md2docx };
package/src/index.js CHANGED
@@ -9,5 +9,7 @@
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
- // eslint-disable-next-line import/prefer-default-export
13
- export { default as mdast2docx } from './mdast2docx/index.js';
12
+ import mdast2docx from './mdast2docx/index.js';
13
+ import md2docx from './md2docx/index.js';
14
+
15
+ export { mdast2docx, md2docx };
@@ -0,0 +1,26 @@
1
+ /*
2
+ * Copyright 2022 Adobe. All rights reserved.
3
+ * This file is licensed to you under the Apache License, Version 2.0 (the "License");
4
+ * you may not use this file except in compliance with the License. You may obtain a copy
5
+ * of the License at http://www.apache.org/licenses/LICENSE-2.0
6
+ *
7
+ * Unless required by applicable law or agreed to in writing, software distributed under
8
+ * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
9
+ * OF ANY KIND, either express or implied. See the License for the specific language
10
+ * governing permissions and limitations under the License.
11
+ */
12
+ import { unified } from 'unified';
13
+ import remark from 'remark-parse';
14
+ import gfm from 'remark-gfm';
15
+ import { remarkMatter } from '@adobe/helix-markdown-support';
16
+ import mdast2docx from '../mdast2docx/index.js';
17
+
18
+ export default async function md2docx(md, log = console) {
19
+ const mdast = unified()
20
+ .use(remark, { position: false })
21
+ .use(gfm)
22
+ .use(remarkMatter)
23
+ .parse(md);
24
+
25
+ return mdast2docx(mdast, log);
26
+ }