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 +46 -23
- package/lib/index.cjs +124 -551
- package/lib/index.cjs.map +1 -1
- package/lib/index.d.ts +1 -0
- package/lib/index.js +125 -552
- package/lib/index.js.map +1 -1
- package/lib/mdast-to-docx.d.ts +6 -19
- package/lib/mdast.d.ts +2 -0
- package/lib/plugin.d.ts +8 -2
- package/lib/plugins/image/index.cjs +96 -0
- package/lib/plugins/image/index.cjs.map +1 -0
- package/lib/plugins/image/index.d.ts +13 -0
- package/lib/plugins/image/index.js +94 -0
- package/lib/plugins/image/index.js.map +1 -0
- package/lib/plugins/math/index.cjs +376 -0
- package/lib/plugins/math/index.cjs.map +1 -0
- package/lib/plugins/math/index.d.ts +5 -0
- package/lib/plugins/math/index.js +374 -0
- package/lib/plugins/math/index.js.map +1 -0
- package/lib/types.d.ts +17 -0
- package/lib/utils-40yKzkXT.js +19 -0
- package/lib/utils-40yKzkXT.js.map +1 -0
- package/lib/utils-EYEfXxbh.js +22 -0
- package/lib/utils-EYEfXxbh.js.map +1 -0
- package/package.json +18 -10
- package/lib/models/mdast.d.ts +0 -21
- /package/lib/{latex.d.ts → plugins/math/parser.d.ts} +0 -0
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
|
-
###
|
|
11
|
+
### Supported mdast nodes
|
|
11
12
|
|
|
12
|
-
|
|
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]
|
|
40
|
-
- [
|
|
41
|
-
- [
|
|
42
|
-
- [
|
|
43
|
-
- [
|
|
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
|
-
##
|
|
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
|
|
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
|
|
72
|
-
saveAs(
|
|
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
|
|
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
|
|
91
|
-
fs.writeFileSync("example.docx",
|
|
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)
|