@adobe/helix-md2docx 1.0.3 → 1.1.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,10 @@
1
+ # [1.1.0](https://github.com/adobe/helix-md2docx/compare/v1.0.3...v1.1.0) (2022-01-19)
2
+
3
+
4
+ ### Features
5
+
6
+ * export md2docx ([42f7e88](https://github.com/adobe/helix-md2docx/commit/42f7e88aa55534a0f9bf3b7ef13a598c2d304003))
7
+
1
8
  ## [1.0.3](https://github.com/adobe/helix-md2docx/compare/v1.0.2...v1.0.3) (2022-01-19)
2
9
 
3
10
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adobe/helix-md2docx",
3
- "version": "1.0.3",
3
+ "version": "1.1.0",
4
4
  "description": "Helix Service that converts markdown to word documents",
5
5
  "main": "src/index.js",
6
6
  "type": "module",
@@ -15,13 +15,9 @@ 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
18
  import { MediaHandler } from '@adobe/helix-mediahandler';
23
19
  import { docx2md } from '@adobe/helix-docx2md';
24
- import { mdast2docx } from '../index.js';
20
+ import { md2docx } from '../index.js';
25
21
 
26
22
  class MockMediaHandler extends MediaHandler {
27
23
  constructor(params) {
@@ -75,13 +71,7 @@ async function run(filePath) {
75
71
  console.log(`converting ${file} -> ${path.relative(process.cwd(), fileDocx)}`);
76
72
 
77
73
  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);
74
+ const buffer = await md2docx(md);
85
75
  await writeFile(fileDocx, buffer);
86
76
 
87
77
  // convert back for verification
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
+ }