@adobe/helix-md2docx 1.0.1 → 1.2.0

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.0](https://github.com/adobe/helix-md2docx/compare/v1.1.0...v1.2.0) (2022-01-20)
2
+
3
+
4
+ ### Features
5
+
6
+ * move cli to get rid of the mediahanlder dep ([b7e8349](https://github.com/adobe/helix-md2docx/commit/b7e8349a0a2e0d06ad9f95b6287a3322e9bba9d9))
7
+
8
+ # [1.1.0](https://github.com/adobe/helix-md2docx/compare/v1.0.3...v1.1.0) (2022-01-19)
9
+
10
+
11
+ ### Features
12
+
13
+ * export md2docx ([42f7e88](https://github.com/adobe/helix-md2docx/commit/42f7e88aa55534a0f9bf3b7ef13a598c2d304003))
14
+
15
+ ## [1.0.3](https://github.com/adobe/helix-md2docx/compare/v1.0.2...v1.0.3) (2022-01-19)
16
+
17
+
18
+ ### Bug Fixes
19
+
20
+ * invalid imports in the cli ([33d698d](https://github.com/adobe/helix-md2docx/commit/33d698d10144a5c9383256a847634e42b8c7f0c8))
21
+
22
+ ## [1.0.2](https://github.com/adobe/helix-md2docx/compare/v1.0.1...v1.0.2) (2022-01-17)
23
+
24
+
25
+ ### Bug Fixes
26
+
27
+ * **deps:** update dependency @adobe/helix-docx2md to v1.0.5 ([98334f6](https://github.com/adobe/helix-md2docx/commit/98334f6365aa9b0e03cd64436fb62605a35d0ff4))
28
+
1
29
  ## [1.0.1](https://github.com/adobe/helix-md2docx/compare/v1.0.0...v1.0.1) (2022-01-17)
2
30
 
3
31
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adobe/helix-md2docx",
3
- "version": "1.0.1",
3
+ "version": "1.2.0",
4
4
  "description": "Helix Service that converts markdown to word documents",
5
5
  "main": "src/index.js",
6
6
  "type": "module",
@@ -30,8 +30,7 @@
30
30
  "@adobe/helix-fetch": "3.0.0",
31
31
  "@adobe/helix-markdown-support": "3.1.1",
32
32
  "@adobe/helix-shared-process-queue": "1.1.0",
33
- "@adobe/helix-docx2md": "1.0.4",
34
- "@adobe/helix-mediahandler": "1.0.1",
33
+ "@adobe/helix-docx2md": "1.0.5",
35
34
  "dirname-filename-esm": "1.1.1",
36
35
  "docx": "7.3.0",
37
36
  "hast-util-is-element": "2.1.1",
@@ -45,13 +44,14 @@
45
44
  },
46
45
  "devDependencies": {
47
46
  "@adobe/eslint-config-helix": "1.3.2",
47
+ "@adobe/helix-mediahandler": "1.0.1",
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": "10.0.0",
54
+ "dotenv": "14.1.0",
55
55
  "eslint": "8.6.0",
56
56
  "eslint-plugin-header": "3.1.1",
57
57
  "eslint-plugin-import": "2.25.4",
@@ -12,52 +12,18 @@
12
12
 
13
13
  /* eslint-disable no-await-in-loop,no-console */
14
14
  import {
15
- readDir, readFile, stat, writeFile,
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 '../mdast2docx/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
57
23
  filePath = path.resolve(process.cwd(), filePath);
58
24
  const files = [];
59
25
  if ((await stat(filePath)).isDirectory()) {
60
- files.push(...await readDir(filePath));
26
+ files.push(...await readdir(filePath));
61
27
  } else {
62
28
  files.push(filePath);
63
29
  }
@@ -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
+ }