remark-docx 0.2.1 → 0.3.1

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/README.md CHANGED
@@ -6,12 +6,11 @@
6
6
 
7
7
  - Uses [docx](https://github.com/dolanmiu/docx) for compilation.
8
8
  - Works in any environment (e.g. browser, Node.js).
9
+ - You can customize [mdast](https://github.com/syntax-tree/mdast) to Word transformation with plugin system.
9
10
 
10
- ### 🚧 WIP 🚧
11
+ ### Supported mdast nodes
11
12
 
12
- This project is aiming to support all nodes in [mdast](https://github.com/syntax-tree/mdast) syntax tree, but currently transformation and stylings may not be well.
13
-
14
- If you have some feature requests or improvements, please create a [issue](https://github.com/inokawa/remark-docx/issues) or [PR](https://github.com/inokawa/remark-docx/pulls).
13
+ Currently, some of the default styles may not be nice. If you have feature requests or improvements, please create a [issue](https://github.com/inokawa/remark-docx/issues) or [PR](https://github.com/inokawa/remark-docx/pulls).
15
14
 
16
15
  - [x] paragraph
17
16
  - [x] heading
@@ -22,25 +21,21 @@ If you have some feature requests or improvements, please create a [issue](https
22
21
  - [x] table
23
22
  - [x] tableRow
24
23
  - [x] tableCell
25
- - [ ] html
26
- - [ ] code
27
- - [ ] yaml
28
- - [ ] toml
29
24
  - [x] definition
30
25
  - [x] footnoteDefinition
31
26
  - [x] text
32
27
  - [x] emphasis
33
28
  - [x] strong
34
29
  - [x] delete
35
- - [ ] inlineCode
36
30
  - [x] break
37
- - [x] link
38
- - [x] image
39
- - [x] linkReference
40
- - [x] imageReference
41
- - [x] footnote
42
- - [x] footnoteReference
43
- - [x] LaTeX support with math and inlineMath ([remark-math](https://github.com/remarkjs/remark-math) is required)
31
+ - [x] link / linkReference
32
+ - [x] image / imageReference ([remark-docx/plugins/image](#image) is required)
33
+ - [x] footnote / footnoteReference
34
+ - [ ] html
35
+ - [ ] yaml
36
+ - [ ] toml
37
+ - [ ] code / inlineCode
38
+ - [x] math / inlineMath ([remark-math](https://github.com/remarkjs/remark-math) and [remark-docx/plugins/math](#latex) are required)
44
39
 
45
40
  ## Demo
46
41
 
@@ -52,7 +47,7 @@ https://inokawa.github.io/remark-docx/
52
47
  npm install remark-docx
53
48
  ```
54
49
 
55
- ## Usage
50
+ ## Getting started
56
51
 
57
52
  ### Browser
58
53
 
@@ -62,14 +57,14 @@ import markdown from "remark-parse";
62
57
  import docx from "remark-docx";
63
58
  import { saveAs } from "file-saver";
64
59
 
65
- const processor = unified().use(markdown).use(docx, { output: "blob" });
60
+ const processor = unified().use(markdown).use(docx);
66
61
 
67
62
  const text = "# hello world";
68
63
 
69
64
  (async () => {
70
65
  const doc = await processor.process(text);
71
- const blob = await doc.result;
72
- saveAs(blob, "example.docx");
66
+ const arrayBuffer = await doc.result;
67
+ saveAs(new Blob([arrayBuffer]), "example.docx");
73
68
  })();
74
69
  ```
75
70
 
@@ -81,17 +76,45 @@ import markdown from "remark-parse";
81
76
  import docx from "remark-docx";
82
77
  import * as fs from "fs";
83
78
 
84
- const processor = unified().use(markdown).use(docx, { output: "buffer" });
79
+ const processor = unified().use(markdown).use(docx);
85
80
 
86
81
  const text = "# hello world";
87
82
 
88
83
  (async () => {
89
84
  const doc = await processor.process(text);
90
- const buffer = await doc.result;
91
- fs.writeFileSync("example.docx", buffer);
85
+ const arrayBuffer = await doc.result;
86
+ fs.writeFileSync("example.docx", Buffer.from(arrayBuffer));
92
87
  })();
93
88
  ```
94
89
 
90
+ ## With plugins
91
+
92
+ ### Image
93
+
94
+ ```javascript
95
+ import { unified } from "unified";
96
+ import markdown from "remark-parse";
97
+ import docx from "remark-docx";
98
+ import { imagePlugin } from "remark-docx/plugins/image";
99
+
100
+ const processor = unified()
101
+ .use(markdown)
102
+ .use(docx, { plugins: [imagePlugin()] });
103
+ ```
104
+
105
+ ### LaTeX
106
+
107
+ ```javascript
108
+ import { unified } from "unified";
109
+ import markdown from "remark-parse";
110
+ import docx from "remark-docx";
111
+ import { latexPlugin } from "remark-docx/plugins/math";
112
+
113
+ const processor = unified()
114
+ .use(markdown)
115
+ .use(docx, { plugins: [latexPlugin()] });
116
+ ```
117
+
95
118
  ## Documentation
96
119
 
97
120
  - [API reference](./docs/API.md)