remark-docx 0.3.17 → 0.3.19
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 +25 -12
- package/lib/index.cjs +150 -91
- package/lib/index.cjs.map +1 -1
- package/lib/index.js +151 -92
- package/lib/index.js.map +1 -1
- package/lib/mdast-util-to-docx.d.ts +19 -2
- package/lib/plugins/image/index.cjs.map +1 -1
- package/lib/plugins/image/index.d.ts +1 -1
- package/lib/plugins/image/index.js.map +1 -1
- package/lib/types.d.ts +2 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -14,7 +14,7 @@ Currently, some of the default styles may not be nice. If you have feature reque
|
|
|
14
14
|
|
|
15
15
|
- [x] paragraph
|
|
16
16
|
- [x] heading
|
|
17
|
-
- [x] thematicBreak
|
|
17
|
+
- [x] thematicBreak (rendered as Page Break/Section Break)
|
|
18
18
|
- [x] blockquote
|
|
19
19
|
- [x] list / listItem
|
|
20
20
|
- [x] table / tableRow / tableCell
|
|
@@ -86,7 +86,7 @@ const text = "# hello world";
|
|
|
86
86
|
|
|
87
87
|
### Image
|
|
88
88
|
|
|
89
|
-
Fetch image data and embed into docx.
|
|
89
|
+
Fetch image data and embed into docx. `png`, `jpg`, `gif`, `bmp`, `svg` urls are supported.
|
|
90
90
|
|
|
91
91
|
```javascript
|
|
92
92
|
import { unified } from "unified";
|
|
@@ -99,6 +99,19 @@ const processor = unified()
|
|
|
99
99
|
.use(docx, { plugins: [imagePlugin()] });
|
|
100
100
|
```
|
|
101
101
|
|
|
102
|
+
When we embed `svg` to docx, it also requires `png` image for compatibility reason. On browser, this plugin generate it automatically. On other enviroment like Node.js, please implement `fallbackSvg` prop.
|
|
103
|
+
|
|
104
|
+
```javascript
|
|
105
|
+
import sharp from "sharp";
|
|
106
|
+
|
|
107
|
+
imagePlugin({
|
|
108
|
+
fallbackSvg: async ({ buffer }) => {
|
|
109
|
+
const png = await sharp(buffer).png().toBuffer();
|
|
110
|
+
return png.buffer;
|
|
111
|
+
},
|
|
112
|
+
});
|
|
113
|
+
```
|
|
114
|
+
|
|
102
115
|
### Code
|
|
103
116
|
|
|
104
117
|
Syntax highlighting with [shiki](https://github.com/shikijs/shiki).
|
|
@@ -114,36 +127,36 @@ const processor = unified()
|
|
|
114
127
|
.use(docx, { plugins: [shikiPlugin({ theme: "dark-plus" })] });
|
|
115
128
|
```
|
|
116
129
|
|
|
117
|
-
###
|
|
130
|
+
### Math
|
|
118
131
|
|
|
119
|
-
|
|
132
|
+
Render LaTeX with [MathJax](https://github.com/mathjax/MathJax).
|
|
120
133
|
|
|
121
134
|
```javascript
|
|
122
135
|
import { unified } from "unified";
|
|
123
136
|
import markdown from "remark-parse";
|
|
137
|
+
import math from "remark-math";
|
|
124
138
|
import docx from "remark-docx";
|
|
125
|
-
import {
|
|
139
|
+
import { latexPlugin } from "remark-docx/plugins/latex";
|
|
126
140
|
|
|
127
141
|
const processor = unified()
|
|
128
142
|
.use(markdown)
|
|
129
|
-
.use(
|
|
143
|
+
.use(math)
|
|
144
|
+
.use(docx, { plugins: [latexPlugin()] });
|
|
130
145
|
```
|
|
131
146
|
|
|
132
|
-
###
|
|
147
|
+
### HTML
|
|
133
148
|
|
|
134
|
-
|
|
149
|
+
Transform HTML to markdown.
|
|
135
150
|
|
|
136
151
|
```javascript
|
|
137
152
|
import { unified } from "unified";
|
|
138
153
|
import markdown from "remark-parse";
|
|
139
|
-
import math from "remark-math";
|
|
140
154
|
import docx from "remark-docx";
|
|
141
|
-
import {
|
|
155
|
+
import { htmlPlugin } from "remark-docx/plugins/html";
|
|
142
156
|
|
|
143
157
|
const processor = unified()
|
|
144
158
|
.use(markdown)
|
|
145
|
-
.use(
|
|
146
|
-
.use(docx, { plugins: [latexPlugin()] });
|
|
159
|
+
.use(docx, { plugins: [htmlPlugin()] });
|
|
147
160
|
```
|
|
148
161
|
|
|
149
162
|
## Documentation
|
package/lib/index.cjs
CHANGED
|
@@ -14,10 +14,11 @@ function warnOnce(message, cond = false) {
|
|
|
14
14
|
}
|
|
15
15
|
}
|
|
16
16
|
|
|
17
|
+
const BULLET_LIST_REF = "bullet";
|
|
17
18
|
const ORDERED_LIST_REF = "ordered";
|
|
18
|
-
const
|
|
19
|
+
const COMPLETE_TASK_LIST_REF = "task-complete";
|
|
20
|
+
const INCOMPLETE_TASK_LIST_REF = "task-incomplete";
|
|
19
21
|
const HYPERLINK_STYLE_ID = "Hyperlink";
|
|
20
|
-
const INLINE_CODE_STYLE_ID = "InlineCode";
|
|
21
22
|
const INDENT = 0.5;
|
|
22
23
|
const createFootnoteRegistry = () => {
|
|
23
24
|
const idToInternalId = new Map();
|
|
@@ -30,12 +31,11 @@ const createFootnoteRegistry = () => {
|
|
|
30
31
|
return internalId;
|
|
31
32
|
};
|
|
32
33
|
return {
|
|
33
|
-
|
|
34
|
+
id: (id) => {
|
|
34
35
|
return getId(id);
|
|
35
36
|
},
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
defs.set(internalId, def);
|
|
37
|
+
set: (id, def) => {
|
|
38
|
+
defs.set(id, def);
|
|
39
39
|
},
|
|
40
40
|
toConfig: () => {
|
|
41
41
|
return defs.entries().reduce((acc, [key, def]) => {
|
|
@@ -47,12 +47,15 @@ const createFootnoteRegistry = () => {
|
|
|
47
47
|
};
|
|
48
48
|
const createNumberingRegistry = () => {
|
|
49
49
|
let counter = 1;
|
|
50
|
+
const ids = [];
|
|
50
51
|
return {
|
|
51
52
|
createId: () => {
|
|
52
|
-
|
|
53
|
+
const id = `${ORDERED_LIST_REF}-${counter++}`;
|
|
54
|
+
ids.push(id);
|
|
55
|
+
return id;
|
|
53
56
|
},
|
|
54
57
|
getIds: () => {
|
|
55
|
-
return
|
|
58
|
+
return ids;
|
|
56
59
|
},
|
|
57
60
|
};
|
|
58
61
|
};
|
|
@@ -73,39 +76,23 @@ const composeBuilders = (pluginsBuilders, defaultBuilders) => {
|
|
|
73
76
|
return acc;
|
|
74
77
|
}, defaultBuilders);
|
|
75
78
|
};
|
|
76
|
-
const
|
|
77
|
-
|
|
78
|
-
{ text
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
{ text: "%1.", format: "DECIMAL" },
|
|
86
|
-
{ text: "%2.", format: "DECIMAL" },
|
|
87
|
-
{ text: "%3.", format: "DECIMAL" },
|
|
88
|
-
{ text: "%4.", format: "DECIMAL" },
|
|
89
|
-
{ text: "%5.", format: "DECIMAL" },
|
|
90
|
-
{ text: "%6.", format: "DECIMAL" },
|
|
91
|
-
];
|
|
92
|
-
const buildLevels = (formats) => formats.map(({ format, text }, i) => {
|
|
93
|
-
return {
|
|
94
|
-
level: i,
|
|
95
|
-
format: docx.LevelFormat[format],
|
|
96
|
-
text: text,
|
|
97
|
-
alignment: docx.AlignmentType.START,
|
|
98
|
-
style: i === 0
|
|
99
|
-
? undefined
|
|
100
|
-
: {
|
|
79
|
+
const buildLevels = (formats) => {
|
|
80
|
+
const INDENT_UNIT = 10 * 40;
|
|
81
|
+
return formats.map(({ format, text }, i) => {
|
|
82
|
+
return {
|
|
83
|
+
level: i,
|
|
84
|
+
format: docx.LevelFormat[format],
|
|
85
|
+
text: text,
|
|
86
|
+
alignment: docx.AlignmentType.LEFT,
|
|
87
|
+
style: {
|
|
101
88
|
paragraph: {
|
|
102
|
-
indent: {
|
|
89
|
+
indent: { hanging: INDENT_UNIT, left: INDENT_UNIT * (i + 1) },
|
|
103
90
|
},
|
|
104
91
|
},
|
|
105
|
-
|
|
106
|
-
});
|
|
107
|
-
|
|
108
|
-
|
|
92
|
+
};
|
|
93
|
+
});
|
|
94
|
+
};
|
|
95
|
+
const mdastToDocx = async (node, { plugins = [], title, subject, creator, keywords, description, styles, size, margin, background, thematicBreak = "page", orderedListFormat, } = {}) => {
|
|
109
96
|
const definition = mdastUtilDefinitions.definitions(node);
|
|
110
97
|
const numbering = createNumberingRegistry();
|
|
111
98
|
const footnote = createFootnoteRegistry();
|
|
@@ -155,6 +142,30 @@ const mdastToDocx = async (node, { plugins = [], title, subject, creator, keywor
|
|
|
155
142
|
}
|
|
156
143
|
return null;
|
|
157
144
|
};
|
|
145
|
+
let { WIDTH: pageWidth, HEIGHT: pageHeight } = docx.sectionPageSizeDefaults;
|
|
146
|
+
if (size) {
|
|
147
|
+
if (size.width != null) {
|
|
148
|
+
pageWidth = size.width;
|
|
149
|
+
}
|
|
150
|
+
if (size.height != null) {
|
|
151
|
+
pageHeight = size.height;
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
let { TOP: marginTop, LEFT: marginLeft, BOTTOM: marginBottom, RIGHT: marginRight, } = docx.sectionMarginDefaults;
|
|
155
|
+
if (margin) {
|
|
156
|
+
if (margin.top != null) {
|
|
157
|
+
marginTop = margin.top;
|
|
158
|
+
}
|
|
159
|
+
if (margin.left != null) {
|
|
160
|
+
marginLeft = margin.left;
|
|
161
|
+
}
|
|
162
|
+
if (margin.bottom != null) {
|
|
163
|
+
marginBottom = margin.bottom;
|
|
164
|
+
}
|
|
165
|
+
if (margin.right != null) {
|
|
166
|
+
marginRight = margin.right;
|
|
167
|
+
}
|
|
168
|
+
}
|
|
158
169
|
const ctx = {
|
|
159
170
|
render(nodes, c) {
|
|
160
171
|
const results = [];
|
|
@@ -166,9 +177,7 @@ const mdastToDocx = async (node, { plugins = [], title, subject, creator, keywor
|
|
|
166
177
|
}
|
|
167
178
|
return results;
|
|
168
179
|
},
|
|
169
|
-
width:
|
|
170
|
-
docx.sectionMarginDefaults.LEFT -
|
|
171
|
-
docx.sectionMarginDefaults.RIGHT,
|
|
180
|
+
width: pageWidth - marginLeft - marginRight,
|
|
172
181
|
deco: {},
|
|
173
182
|
indent: 0,
|
|
174
183
|
thematicBreak,
|
|
@@ -190,43 +199,88 @@ const mdastToDocx = async (node, { plugins = [], title, subject, creator, keywor
|
|
|
190
199
|
}
|
|
191
200
|
}
|
|
192
201
|
}
|
|
193
|
-
const orderedLevels = buildLevels(orderedListFormat
|
|
202
|
+
const orderedLevels = buildLevels(orderedListFormat !== null && orderedListFormat !== void 0 ? orderedListFormat : [
|
|
203
|
+
{ text: "%1.", format: "DECIMAL" },
|
|
204
|
+
{ text: "%2.", format: "DECIMAL" },
|
|
205
|
+
{ text: "%3.", format: "DECIMAL" },
|
|
206
|
+
{ text: "%4.", format: "DECIMAL" },
|
|
207
|
+
{ text: "%5.", format: "DECIMAL" },
|
|
208
|
+
{ text: "%6.", format: "DECIMAL" },
|
|
209
|
+
]);
|
|
210
|
+
const sectionProperties = {
|
|
211
|
+
page: {
|
|
212
|
+
size: { width: pageWidth, height: pageHeight },
|
|
213
|
+
margin: {
|
|
214
|
+
top: marginTop,
|
|
215
|
+
left: marginLeft,
|
|
216
|
+
bottom: marginBottom,
|
|
217
|
+
right: marginRight,
|
|
218
|
+
},
|
|
219
|
+
},
|
|
220
|
+
};
|
|
194
221
|
const doc = new docx.Document({
|
|
195
222
|
title,
|
|
196
223
|
subject,
|
|
197
224
|
creator,
|
|
198
225
|
keywords,
|
|
199
226
|
description,
|
|
200
|
-
styles:
|
|
201
|
-
...styles,
|
|
202
|
-
characterStyles: [
|
|
203
|
-
...((_a = styles === null || styles === void 0 ? void 0 : styles.characterStyles) !== null && _a !== void 0 ? _a : []),
|
|
204
|
-
{
|
|
205
|
-
id: INLINE_CODE_STYLE_ID,
|
|
206
|
-
run: {
|
|
207
|
-
highlight: "lightGray",
|
|
208
|
-
},
|
|
209
|
-
},
|
|
210
|
-
],
|
|
211
|
-
},
|
|
227
|
+
styles: styles,
|
|
212
228
|
background,
|
|
213
229
|
sections: sections
|
|
214
230
|
.filter((s) => s.length)
|
|
215
|
-
.map((s) => ({
|
|
231
|
+
.map((s) => ({
|
|
232
|
+
properties: sectionProperties,
|
|
233
|
+
children: s,
|
|
234
|
+
})),
|
|
216
235
|
footnotes: footnote.toConfig(),
|
|
217
236
|
numbering: {
|
|
218
237
|
config: [
|
|
238
|
+
{
|
|
239
|
+
reference: BULLET_LIST_REF,
|
|
240
|
+
levels: buildLevels([
|
|
241
|
+
{ text: "\u25CF", format: "BULLET" },
|
|
242
|
+
{ text: "\u25CB", format: "BULLET" },
|
|
243
|
+
{ text: "\u25A0", format: "BULLET" },
|
|
244
|
+
{ text: "\u25CF", format: "BULLET" },
|
|
245
|
+
{ text: "\u25CB", format: "BULLET" },
|
|
246
|
+
{ text: "\u25A0", format: "BULLET" },
|
|
247
|
+
]),
|
|
248
|
+
},
|
|
219
249
|
...numbering.getIds().map((ref) => ({
|
|
220
250
|
reference: ref,
|
|
221
251
|
levels: orderedLevels,
|
|
222
252
|
})),
|
|
223
253
|
{
|
|
224
|
-
reference:
|
|
225
|
-
levels: buildLevels(
|
|
254
|
+
reference: COMPLETE_TASK_LIST_REF,
|
|
255
|
+
levels: buildLevels([
|
|
256
|
+
{ text: "\u2611", format: "BULLET" },
|
|
257
|
+
{ text: "\u2611", format: "BULLET" },
|
|
258
|
+
{ text: "\u2611", format: "BULLET" },
|
|
259
|
+
{ text: "\u2611", format: "BULLET" },
|
|
260
|
+
{ text: "\u2611", format: "BULLET" },
|
|
261
|
+
{ text: "\u2611", format: "BULLET" },
|
|
262
|
+
]),
|
|
263
|
+
},
|
|
264
|
+
{
|
|
265
|
+
reference: INCOMPLETE_TASK_LIST_REF,
|
|
266
|
+
levels: buildLevels([
|
|
267
|
+
{ text: "\u2610", format: "BULLET" },
|
|
268
|
+
{ text: "\u2610", format: "BULLET" },
|
|
269
|
+
{ text: "\u2610", format: "BULLET" },
|
|
270
|
+
{ text: "\u2610", format: "BULLET" },
|
|
271
|
+
{ text: "\u2610", format: "BULLET" },
|
|
272
|
+
{ text: "\u2610", format: "BULLET" },
|
|
273
|
+
]),
|
|
226
274
|
},
|
|
227
275
|
],
|
|
228
276
|
},
|
|
229
277
|
});
|
|
278
|
+
// HACK: docx.js has no way to remove default numberings styles from .docx. So do it here for now.
|
|
279
|
+
// https://github.com/dolanmiu/docx/blob/master/src/file/numbering/numbering.ts
|
|
280
|
+
const defaultBulletKey = "default-bullet-numbering";
|
|
281
|
+
const _numbering = doc.numbering;
|
|
282
|
+
_numbering.abstractNumberingMap.delete(defaultBulletKey);
|
|
283
|
+
_numbering.concreteNumberingMap.delete(defaultBulletKey);
|
|
230
284
|
return docx.Packer.toArrayBuffer(doc);
|
|
231
285
|
};
|
|
232
286
|
const buildParagraph = ({ children }, ctx) => {
|
|
@@ -243,13 +297,10 @@ const buildParagraph = ({ children }, ctx) => {
|
|
|
243
297
|
if (list) {
|
|
244
298
|
const { level, meta } = list;
|
|
245
299
|
if (meta.type === "task") {
|
|
246
|
-
nodes.unshift(new docx.CheckBox({
|
|
247
|
-
checked: meta.checked,
|
|
248
|
-
checkedState: { value: "2611" },
|
|
249
|
-
uncheckedState: { value: "2610" },
|
|
250
|
-
}));
|
|
251
300
|
options.numbering = {
|
|
252
|
-
reference:
|
|
301
|
+
reference: meta.checked
|
|
302
|
+
? COMPLETE_TASK_LIST_REF
|
|
303
|
+
: INCOMPLETE_TASK_LIST_REF,
|
|
253
304
|
level,
|
|
254
305
|
};
|
|
255
306
|
}
|
|
@@ -260,7 +311,8 @@ const buildParagraph = ({ children }, ctx) => {
|
|
|
260
311
|
};
|
|
261
312
|
}
|
|
262
313
|
else {
|
|
263
|
-
options.
|
|
314
|
+
options.numbering = {
|
|
315
|
+
reference: BULLET_LIST_REF,
|
|
264
316
|
level,
|
|
265
317
|
};
|
|
266
318
|
}
|
|
@@ -268,31 +320,30 @@ const buildParagraph = ({ children }, ctx) => {
|
|
|
268
320
|
return new docx.Paragraph(options);
|
|
269
321
|
};
|
|
270
322
|
const buildHeading = ({ children, depth }, ctx) => {
|
|
271
|
-
let
|
|
323
|
+
let level;
|
|
272
324
|
switch (depth) {
|
|
273
325
|
case 1:
|
|
274
|
-
|
|
326
|
+
level = "TITLE";
|
|
275
327
|
break;
|
|
276
328
|
case 2:
|
|
277
|
-
|
|
329
|
+
level = "HEADING_1";
|
|
278
330
|
break;
|
|
279
331
|
case 3:
|
|
280
|
-
|
|
332
|
+
level = "HEADING_2";
|
|
281
333
|
break;
|
|
282
334
|
case 4:
|
|
283
|
-
|
|
335
|
+
level = "HEADING_3";
|
|
284
336
|
break;
|
|
285
337
|
case 5:
|
|
286
|
-
|
|
338
|
+
level = "HEADING_4";
|
|
287
339
|
break;
|
|
288
340
|
case 6:
|
|
289
|
-
|
|
341
|
+
level = "HEADING_5";
|
|
290
342
|
break;
|
|
291
343
|
}
|
|
292
|
-
const nodes = ctx.render(children);
|
|
293
344
|
return new docx.Paragraph({
|
|
294
|
-
heading:
|
|
295
|
-
children:
|
|
345
|
+
heading: docx.HeadingLevel[level],
|
|
346
|
+
children: ctx.render(children),
|
|
296
347
|
});
|
|
297
348
|
};
|
|
298
349
|
const buildThematicBreak = (_, ctx) => {
|
|
@@ -350,16 +401,16 @@ const buildListItem = ({ children, checked }, ctx) => {
|
|
|
350
401
|
});
|
|
351
402
|
};
|
|
352
403
|
const buildTable = ({ children, align }, ctx) => {
|
|
353
|
-
const
|
|
404
|
+
const textAlign = align === null || align === void 0 ? void 0 : align.map((a) => {
|
|
354
405
|
switch (a) {
|
|
355
406
|
case "left":
|
|
356
|
-
return
|
|
407
|
+
return "LEFT";
|
|
357
408
|
case "right":
|
|
358
|
-
return
|
|
409
|
+
return "RIGHT";
|
|
359
410
|
case "center":
|
|
360
|
-
return
|
|
411
|
+
return "CENTER";
|
|
361
412
|
default:
|
|
362
|
-
return
|
|
413
|
+
return "LEFT";
|
|
363
414
|
}
|
|
364
415
|
});
|
|
365
416
|
const columnLength = children[0].children.length;
|
|
@@ -369,11 +420,12 @@ const buildTable = ({ children, align }, ctx) => {
|
|
|
369
420
|
rows: children.map((r) => {
|
|
370
421
|
return new docx.TableRow({
|
|
371
422
|
children: r.children.map((c, i) => {
|
|
423
|
+
var _a;
|
|
372
424
|
return new docx.TableCell({
|
|
373
425
|
width: { size: columnWidth, type: "dxa" },
|
|
374
426
|
children: [
|
|
375
427
|
new docx.Paragraph({
|
|
376
|
-
alignment:
|
|
428
|
+
alignment: docx.AlignmentType[(_a = textAlign === null || textAlign === void 0 ? void 0 : textAlign[i]) !== null && _a !== void 0 ? _a : "LEFT"],
|
|
377
429
|
children: ctx.render(c.children),
|
|
378
430
|
}),
|
|
379
431
|
],
|
|
@@ -390,6 +442,9 @@ const buildText = ({ value }, { deco }) => {
|
|
|
390
442
|
italics: deco.italic,
|
|
391
443
|
strike: deco.strike,
|
|
392
444
|
};
|
|
445
|
+
if (deco.inlineCode) {
|
|
446
|
+
options.highlight = "lightGray";
|
|
447
|
+
}
|
|
393
448
|
if (deco.link) {
|
|
394
449
|
// https://docx.js.org/#/usage/hyperlinks?id=styling-hyperlinks
|
|
395
450
|
options.style = HYPERLINK_STYLE_ID;
|
|
@@ -414,23 +469,26 @@ const buildDelete = ({ children }, ctx) => {
|
|
|
414
469
|
deco: { ...ctx.deco, strike: true },
|
|
415
470
|
});
|
|
416
471
|
};
|
|
417
|
-
const buildInlineCode = ({ value }) => {
|
|
418
|
-
return
|
|
419
|
-
|
|
420
|
-
|
|
472
|
+
const buildInlineCode = ({ value }, ctx) => {
|
|
473
|
+
return buildText({ value }, {
|
|
474
|
+
...ctx,
|
|
475
|
+
deco: { ...ctx.deco, inlineCode: true },
|
|
421
476
|
});
|
|
422
477
|
};
|
|
423
478
|
const buildBreak = () => {
|
|
424
479
|
return new docx.TextRun({ text: "", break: 1 });
|
|
425
480
|
};
|
|
426
481
|
const buildLink = ({ children, url }, ctx) => {
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
}
|
|
482
|
+
if (url.startsWith("#")) {
|
|
483
|
+
// TODO support anchor link
|
|
484
|
+
return ctx.render(children);
|
|
485
|
+
}
|
|
431
486
|
return new docx.ExternalHyperlink({
|
|
432
487
|
link: url,
|
|
433
|
-
children:
|
|
488
|
+
children: ctx.render(children, {
|
|
489
|
+
...ctx,
|
|
490
|
+
deco: { ...ctx.deco, link: true },
|
|
491
|
+
}),
|
|
434
492
|
});
|
|
435
493
|
};
|
|
436
494
|
const buildLinkReference = ({ children, identifier }, ctx) => {
|
|
@@ -441,11 +499,12 @@ const buildLinkReference = ({ children, identifier }, ctx) => {
|
|
|
441
499
|
return buildLink({ children, url: def.url }, ctx);
|
|
442
500
|
};
|
|
443
501
|
const buildFootnoteDefinition = ({ children, identifier }, ctx) => {
|
|
444
|
-
|
|
502
|
+
const contents = ctx.render(children).filter((c) => c instanceof docx.Paragraph);
|
|
503
|
+
ctx.footnote.set(ctx.footnote.id(identifier), contents);
|
|
445
504
|
return null;
|
|
446
505
|
};
|
|
447
506
|
const buildFootnoteReference = ({ identifier }, ctx) => {
|
|
448
|
-
return new docx.FootnoteReferenceRun(ctx.footnote.
|
|
507
|
+
return new docx.FootnoteReferenceRun(ctx.footnote.id(identifier));
|
|
449
508
|
};
|
|
450
509
|
const noop = () => {
|
|
451
510
|
return null;
|
package/lib/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","sources":["../src/src/utils.ts","../src/src/mdast-util-to-docx.ts","../src/src/plugin.ts"],"sourcesContent":["const alreadyWarned: { [message: string]: boolean } = {};\n\n/**\n * @internal\n */\nexport function warnOnce(message: string, cond: boolean = false): void {\n if (!cond && !alreadyWarned[message]) {\n alreadyWarned[message] = true;\n console.warn(message);\n }\n}\n","import {\n convertInchesToTwip,\n Packer,\n Document,\n Paragraph,\n Table,\n TableRow,\n TableCell,\n TextRun,\n ExternalHyperlink,\n HeadingLevel,\n LevelFormat,\n AlignmentType,\n type ILevelsOptions,\n FootnoteReferenceRun,\n CheckBox,\n type IPropertiesOptions,\n sectionPageSizeDefaults,\n sectionMarginDefaults,\n type IRunOptions,\n type IParagraphOptions,\n PageBreak,\n} from \"docx\";\nimport type * as mdast from \"mdast\";\nimport { warnOnce } from \"./utils\";\nimport { definitions } from \"mdast-util-definitions\";\nimport type {\n Context,\n DocxChild,\n DocxContent,\n FootnoteRegistry,\n ListContext,\n NodeBuilder,\n NodeBuilders,\n RemarkDocxPlugin,\n ThematicBreakType,\n Writeable,\n} from \"./types\";\n\nconst ORDERED_LIST_REF = \"ordered\";\nconst TASK_LIST_REF = \"task\";\nconst HYPERLINK_STYLE_ID = \"Hyperlink\";\nconst INLINE_CODE_STYLE_ID = \"InlineCode\";\nconst INDENT = 0.5;\n\nconst createFootnoteRegistry = (): FootnoteRegistry => {\n const idToInternalId = new Map<string, number>();\n const defs = new Map<number, Paragraph[]>();\n\n const getId = (id: string): number => {\n let internalId = idToInternalId.get(id);\n if (internalId == null) {\n idToInternalId.set(id, (internalId = idToInternalId.size + 1));\n }\n return internalId;\n };\n\n return {\n ref: (id) => {\n return getId(id);\n },\n def: (id, def) => {\n const internalId = getId(id);\n defs.set(internalId, def);\n },\n toConfig: () => {\n return defs.entries().reduce(\n (acc, [key, def]) => {\n acc[key] = { children: def };\n return acc;\n },\n {} as {\n [key: string]: { children: Paragraph[] };\n },\n );\n },\n };\n};\n\ntype ListFormat = {\n format: keyof typeof LevelFormat;\n text: string;\n};\n\ntype NumberingRegistry = {\n createId: () => string;\n getIds: () => string[];\n};\nconst createNumberingRegistry = (): NumberingRegistry => {\n let counter = 1;\n\n return {\n createId: () => {\n return `${ORDERED_LIST_REF}-${counter++}`;\n },\n getIds: () => {\n return Array.from(\n { length: counter },\n (_, i) => `${ORDERED_LIST_REF}-${i}`,\n );\n },\n };\n};\n\nconst composeBuilders = (\n pluginsBuilders: readonly NodeBuilders[],\n defaultBuilders: NodeBuilders,\n): NodeBuilders => {\n return pluginsBuilders.reduceRight<NodeBuilders>((acc, p) => {\n type Key = keyof typeof p;\n for (const [k, cur] of Object.entries(p)) {\n const prev = acc[k as Key];\n acc[k as Key] = (\n prev\n ? (n, c) => {\n const r = cur(n as any, c);\n if (r) {\n return r;\n }\n return prev(n as any, c);\n }\n : cur\n ) as NodeBuilder<any>;\n }\n return acc;\n }, defaultBuilders);\n};\nconst defaultTaskList: ListFormat[] = [\n { text: \"\", format: \"NONE\" },\n { text: \"\", format: \"NONE\" },\n { text: \"\", format: \"NONE\" },\n { text: \"\", format: \"NONE\" },\n { text: \"\", format: \"NONE\" },\n { text: \"\", format: \"NONE\" },\n];\n\nconst defaultOrderedList: ListFormat[] = [\n { text: \"%1.\", format: \"DECIMAL\" },\n { text: \"%2.\", format: \"DECIMAL\" },\n { text: \"%3.\", format: \"DECIMAL\" },\n { text: \"%4.\", format: \"DECIMAL\" },\n { text: \"%5.\", format: \"DECIMAL\" },\n { text: \"%6.\", format: \"DECIMAL\" },\n];\n\nconst buildLevels = (formats: readonly ListFormat[]): ILevelsOptions[] =>\n formats.map(({ format, text }, i) => {\n return {\n level: i,\n format: LevelFormat[format],\n text: text,\n alignment: AlignmentType.START,\n style:\n i === 0\n ? undefined\n : {\n paragraph: {\n indent: { start: convertInchesToTwip(INDENT * i) },\n },\n },\n };\n });\n\nexport interface DocxOptions extends Pick<\n IPropertiesOptions,\n | \"title\"\n | \"subject\"\n | \"creator\"\n | \"keywords\"\n | \"description\"\n | \"styles\"\n | \"background\"\n> {\n /**\n * An option to override the text format of ordered list.\n * See https://docx.js.org/#/usage/numbering?id=level-options for more details.\n * @default {@link defaultOrderedList}\n */\n orderedListFormat?: ListFormat[];\n /**\n * An option to select how thematicBreak works. \"page\" is Page Break. \"section\" is Section Break.\n * @default \"page\"\n */\n thematicBreak?: ThematicBreakType;\n /**\n * Plugins to customize how mdast nodes are compiled.\n */\n plugins?: RemarkDocxPlugin[];\n}\n\nexport const mdastToDocx = async (\n node: mdast.Root,\n {\n plugins = [],\n title,\n subject,\n creator,\n keywords,\n description,\n styles,\n background,\n thematicBreak = \"page\",\n orderedListFormat = defaultOrderedList,\n }: DocxOptions = {},\n): Promise<ArrayBuffer> => {\n const definition = definitions(node);\n\n const numbering = createNumberingRegistry();\n const footnote = createFootnoteRegistry();\n\n const pluginCtx = { root: node, definition };\n\n const builders = composeBuilders(\n await Promise.all(plugins.map((p) => p(pluginCtx))),\n {\n paragraph: buildParagraph,\n heading: buildHeading,\n thematicBreak: buildThematicBreak,\n blockquote: buildBlockquote,\n list: buildList,\n listItem: buildListItem,\n table: buildTable,\n tableRow: noop,\n tableCell: noop,\n html: fallbackText,\n code: fallbackText,\n definition: noop,\n footnoteDefinition: buildFootnoteDefinition,\n text: buildText,\n emphasis: buildEmphasis,\n strong: buildStrong,\n delete: buildDelete,\n inlineCode: buildInlineCode,\n break: buildBreak,\n link: buildLink,\n linkReference: buildLinkReference,\n // image: warnImage,\n // imageReference: warnImage,\n footnoteReference: buildFootnoteReference,\n math: fallbackText,\n inlineMath: fallbackText,\n },\n );\n\n const renderNode = (\n node: mdast.RootContent,\n c: Context,\n ): DocxContent[] | null => {\n const builder = builders[node.type];\n if (!builder) {\n warnOnce(`${node.type} node is not supported without plugins.`);\n return null;\n }\n const r = builder(node as any, c);\n if (r) {\n if (Array.isArray(r)) {\n return r;\n } else {\n return [r];\n }\n }\n return null;\n };\n\n const ctx: Context = {\n render(nodes, c) {\n const results: DocxContent[] = [];\n for (const node of nodes) {\n const r = renderNode(node, c ?? this);\n if (r) {\n results.push(...r);\n }\n }\n return results;\n },\n width:\n sectionPageSizeDefaults.WIDTH -\n sectionMarginDefaults.LEFT -\n sectionMarginDefaults.RIGHT,\n deco: {},\n indent: 0,\n thematicBreak,\n definition: definition,\n footnote,\n orderedId: numbering.createId,\n };\n\n const sections: DocxContent[][] = [[]];\n for (const n of node.children) {\n const r = renderNode(n, ctx);\n if (r) {\n if (!r.length) {\n // thematicBreak\n sections.push([]);\n } else {\n const lastSection = sections[sections.length - 1]!;\n lastSection.push(...r);\n }\n }\n }\n\n const orderedLevels = buildLevels(orderedListFormat);\n\n const doc = new Document({\n title,\n subject,\n creator,\n keywords,\n description,\n styles: {\n ...styles,\n characterStyles: [\n ...(styles?.characterStyles ?? []),\n {\n id: INLINE_CODE_STYLE_ID,\n run: {\n highlight: \"lightGray\",\n },\n },\n ],\n },\n background,\n sections: sections\n .filter((s) => s.length)\n .map((s) => ({ children: s as DocxChild[] })),\n footnotes: footnote.toConfig(),\n numbering: {\n config: [\n ...numbering.getIds().map((ref) => ({\n reference: ref,\n levels: orderedLevels,\n })),\n {\n reference: TASK_LIST_REF,\n levels: buildLevels(defaultTaskList),\n },\n ],\n },\n });\n\n return Packer.toArrayBuffer(doc);\n};\n\nconst buildParagraph: NodeBuilder<\"paragraph\"> = ({ children }, ctx) => {\n const list = ctx.list;\n const nodes = ctx.render(children);\n\n const options: Writeable<IParagraphOptions> = {\n children: nodes,\n };\n\n if (ctx.indent > 0) {\n options.indent = {\n start: convertInchesToTwip(INDENT * ctx.indent),\n };\n }\n\n if (list) {\n const { level, meta } = list;\n if (meta.type === \"task\") {\n nodes.unshift(\n new CheckBox({\n checked: meta.checked,\n checkedState: { value: \"2611\" },\n uncheckedState: { value: \"2610\" },\n }),\n );\n options.numbering = {\n reference: TASK_LIST_REF,\n level,\n };\n } else if (meta.type === \"ordered\") {\n options.numbering = {\n reference: meta.reference,\n level,\n };\n } else {\n options.bullet = {\n level,\n };\n }\n }\n\n return new Paragraph(options);\n};\n\nconst buildHeading: NodeBuilder<\"heading\"> = ({ children, depth }, ctx) => {\n let headingLevel: (typeof HeadingLevel)[keyof typeof HeadingLevel];\n switch (depth) {\n case 1:\n headingLevel = HeadingLevel.TITLE;\n break;\n case 2:\n headingLevel = HeadingLevel.HEADING_1;\n break;\n case 3:\n headingLevel = HeadingLevel.HEADING_2;\n break;\n case 4:\n headingLevel = HeadingLevel.HEADING_3;\n break;\n case 5:\n headingLevel = HeadingLevel.HEADING_4;\n break;\n case 6:\n headingLevel = HeadingLevel.HEADING_5;\n break;\n }\n const nodes = ctx.render(children);\n return new Paragraph({\n heading: headingLevel,\n children: nodes,\n });\n};\n\nconst buildThematicBreak: NodeBuilder<\"thematicBreak\"> = (_, ctx) => {\n if (ctx.thematicBreak === \"section\") {\n // Returning empty array at toplevel means section insertion.\n return [];\n }\n return new Paragraph({ children: [new PageBreak()] });\n};\n\nconst buildBlockquote: NodeBuilder<\"blockquote\"> = ({ children }, ctx) => {\n return ctx.render(children, {\n ...ctx,\n indent: ctx.indent + 1,\n });\n};\n\nconst buildList: NodeBuilder<\"list\"> = ({ children, ordered }, ctx) => {\n const parentList = ctx.list;\n\n let meta: ListContext[\"meta\"];\n if (ordered) {\n meta = {\n type: \"ordered\",\n reference:\n parentList && parentList.meta.type === \"ordered\"\n ? parentList.meta.reference\n : ctx.orderedId(),\n };\n } else {\n meta = { type: \"bullet\" };\n }\n\n return ctx.render(children, {\n ...ctx,\n list: {\n level: !parentList ? 0 : parentList.level + 1,\n meta,\n },\n });\n};\n\nconst buildListItem: NodeBuilder<\"listItem\"> = ({ children, checked }, ctx) => {\n let list = ctx.list;\n if (list) {\n // listItem must be the child of list\n if (checked != null) {\n list = {\n level: list.level,\n meta: {\n type: \"task\",\n checked,\n },\n };\n }\n }\n return ctx.render(children, {\n ...ctx,\n list,\n });\n};\n\nconst buildTable: NodeBuilder<\"table\"> = ({ children, align }, ctx) => {\n const cellAligns:\n | (typeof AlignmentType)[keyof typeof AlignmentType][]\n | undefined = align?.map((a) => {\n switch (a) {\n case \"left\":\n return AlignmentType.LEFT;\n case \"right\":\n return AlignmentType.RIGHT;\n case \"center\":\n return AlignmentType.CENTER;\n default:\n return AlignmentType.LEFT;\n }\n });\n\n const columnLength = children[0]!.children.length;\n const columnWidth = ctx.width / columnLength;\n\n return new Table({\n columnWidths: Array.from({ length: columnLength }).map(() => columnWidth),\n rows: children.map((r) => {\n return new TableRow({\n children: r.children.map((c, i) => {\n return new TableCell({\n width: { size: columnWidth, type: \"dxa\" },\n children: [\n new Paragraph({\n alignment: cellAligns?.[i],\n children: ctx.render(c.children),\n }),\n ],\n });\n }),\n });\n }),\n });\n};\n\nconst buildText: NodeBuilder<\"text\"> = ({ value }, { deco }) => {\n const options: Writeable<IRunOptions> = {\n text: value,\n bold: deco.bold,\n italics: deco.italic,\n strike: deco.strike,\n };\n if (deco.link) {\n // https://docx.js.org/#/usage/hyperlinks?id=styling-hyperlinks\n options.style = HYPERLINK_STYLE_ID;\n }\n return new TextRun(options);\n};\n\nconst buildEmphasis: NodeBuilder<\"emphasis\"> = ({ children }, ctx) => {\n return ctx.render(children, {\n ...ctx,\n deco: { ...ctx.deco, italic: true },\n });\n};\n\nconst buildStrong: NodeBuilder<\"strong\"> = ({ children }, ctx) => {\n return ctx.render(children, {\n ...ctx,\n deco: { ...ctx.deco, bold: true },\n });\n};\n\nconst buildDelete: NodeBuilder<\"delete\"> = ({ children }, ctx) => {\n return ctx.render(children, {\n ...ctx,\n deco: { ...ctx.deco, strike: true },\n });\n};\n\nconst buildInlineCode: NodeBuilder<\"inlineCode\"> = ({ value }) => {\n return new TextRun({\n text: value,\n style: INLINE_CODE_STYLE_ID,\n });\n};\n\nconst buildBreak: NodeBuilder<\"break\"> = () => {\n return new TextRun({ text: \"\", break: 1 });\n};\n\nconst buildLink: NodeBuilder<\"link\"> = ({ children, url }, ctx) => {\n const nodes = ctx.render(children, {\n ...ctx,\n deco: { ...ctx.deco, link: true },\n });\n return new ExternalHyperlink({\n link: url,\n children: nodes,\n });\n};\n\nconst buildLinkReference: NodeBuilder<\"linkReference\"> = (\n { children, identifier },\n ctx,\n) => {\n const def = ctx.definition(identifier);\n if (def == null) {\n return ctx.render(children);\n }\n return buildLink({ type: \"link\", children, url: def.url }, ctx);\n};\n\nconst buildFootnoteDefinition: NodeBuilder<\"footnoteDefinition\"> = (\n { children, identifier },\n ctx,\n) => {\n ctx.footnote.def(\n identifier,\n ctx.render(children).filter((c) => c instanceof Paragraph),\n );\n return null;\n};\n\nconst buildFootnoteReference: NodeBuilder<\"footnoteReference\"> = (\n { identifier },\n ctx,\n) => {\n return new FootnoteReferenceRun(ctx.footnote.ref(identifier));\n};\n\nconst noop = () => {\n return null;\n};\n\nconst fallbackText = (node: { type: string; value: string }, ctx: Context) => {\n warnOnce(\n `${node.type} node is not supported without plugins, falling back to text.`,\n );\n return buildText({ type: \"text\", value: node.value }, ctx);\n};\n","import type { Plugin } from \"unified\";\nimport type { Root } from \"mdast\";\nimport { mdastToDocx, type DocxOptions } from \"./mdast-util-to-docx\";\n\nexport type { DocxOptions };\n\ndeclare module \"unified\" {\n interface CompileResultMap {\n docx: Promise<ArrayBuffer>;\n }\n}\n\nconst plugin: Plugin<[DocxOptions?], Root, Promise<ArrayBuffer>> = function (\n opts,\n) {\n this.compiler = (node) => {\n return mdastToDocx(node as Root, opts);\n };\n};\nexport default plugin;\n"],"names":["LevelFormat","AlignmentType","convertInchesToTwip","definitions","sectionPageSizeDefaults","sectionMarginDefaults","Document","Packer","CheckBox","Paragraph","HeadingLevel","PageBreak","Table","TableRow","TableCell","TextRun","ExternalHyperlink","FootnoteReferenceRun"],"mappings":";;;;;AAAA,MAAM,aAAa,GAAmC,EAAE;AAExD;;AAEG;SACa,QAAQ,CAAC,OAAe,EAAE,OAAgB,KAAK,EAAA;IAC7D,IAAI,CAAC,IAAI,IAAI,CAAC,aAAa,CAAC,OAAO,CAAC,EAAE;AACpC,QAAA,aAAa,CAAC,OAAO,CAAC,GAAG,IAAI;AAC7B,QAAA,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC;IACvB;AACF;;AC6BA,MAAM,gBAAgB,GAAG,SAAS;AAClC,MAAM,aAAa,GAAG,MAAM;AAC5B,MAAM,kBAAkB,GAAG,WAAW;AACtC,MAAM,oBAAoB,GAAG,YAAY;AACzC,MAAM,MAAM,GAAG,GAAG;AAElB,MAAM,sBAAsB,GAAG,MAAuB;AACpD,IAAA,MAAM,cAAc,GAAG,IAAI,GAAG,EAAkB;AAChD,IAAA,MAAM,IAAI,GAAG,IAAI,GAAG,EAAuB;AAE3C,IAAA,MAAM,KAAK,GAAG,CAAC,EAAU,KAAY;QACnC,IAAI,UAAU,GAAG,cAAc,CAAC,GAAG,CAAC,EAAE,CAAC;AACvC,QAAA,IAAI,UAAU,IAAI,IAAI,EAAE;AACtB,YAAA,cAAc,CAAC,GAAG,CAAC,EAAE,GAAG,UAAU,GAAG,cAAc,CAAC,IAAI,G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AAC,UAAU,CAAC,CAAC;AAC/D,CAAC;AAED,MAAM,IAAI,GAAG,MAAK;AAChB,IAAA,OAAO,IAAI;AACb,CAAC;AAED,MAAM,YAAY,GAAG,CAAC,IAAqC,EAAE,GAAY,KAAI;AAC3E,IAAA,QAAQ,CACN,CAAA,EAAG,IAAI,CAAC,IAAI,CAAA,6DAAA,CAA+D,CAC5E;AACD,IAAA,OAAO,SAAS,CAAC,EAAgB,KAAK,EAAE,IAAI,CAAC,KAAK,EAAE,EAAE,GAAG,CAAC;AAC5D,CAAC;;ACrlBD,MAAM,MAAM,GAAuD,UACjE,IAAI,EAAA;AAEJ,IAAA,IAAI,CAAC,QAAQ,GAAG,CAAC,IAAI,KAAI;AACvB,QAAA,OAAO,WAAW,CAAC,IAAY,EAAE,IAAI,CAAC;AACxC,IAAA,CAAC;AACH;;;;"}
|
|
1
|
+
{"version":3,"file":"index.cjs","sources":["../src/src/utils.ts","../src/src/mdast-util-to-docx.ts","../src/src/plugin.ts"],"sourcesContent":["const alreadyWarned: { [message: string]: boolean } = {};\n\n/**\n * @internal\n */\nexport function warnOnce(message: string, cond: boolean = false): void {\n if (!cond && !alreadyWarned[message]) {\n alreadyWarned[message] = true;\n console.warn(message);\n }\n}\n","import {\n convertInchesToTwip,\n Packer,\n Document,\n Paragraph,\n Table,\n TableRow,\n TableCell,\n TextRun,\n ExternalHyperlink,\n HeadingLevel,\n LevelFormat,\n AlignmentType,\n type ILevelsOptions,\n FootnoteReferenceRun,\n type IPropertiesOptions,\n sectionPageSizeDefaults,\n sectionMarginDefaults,\n type IRunOptions,\n type IParagraphOptions,\n PageBreak,\n type ISectionPropertiesOptions,\n} from \"docx\";\nimport type * as mdast from \"mdast\";\nimport { warnOnce } from \"./utils\";\nimport { definitions } from \"mdast-util-definitions\";\nimport type {\n Context,\n DocxChild,\n DocxContent,\n FootnoteRegistry,\n ListContext,\n NodeBuilder,\n NodeBuilders,\n RemarkDocxPlugin,\n ThematicBreakType,\n Writeable,\n} from \"./types\";\n\nconst BULLET_LIST_REF = \"bullet\";\nconst ORDERED_LIST_REF = \"ordered\";\nconst COMPLETE_TASK_LIST_REF = \"task-complete\";\nconst INCOMPLETE_TASK_LIST_REF = \"task-incomplete\";\nconst HYPERLINK_STYLE_ID = \"Hyperlink\";\nconst INDENT = 0.5;\n\nconst createFootnoteRegistry = (): FootnoteRegistry => {\n const idToInternalId = new Map<string, number>();\n const defs = new Map<number, Paragraph[]>();\n\n const getId = (id: string): number => {\n let internalId = idToInternalId.get(id);\n if (internalId == null) {\n idToInternalId.set(id, (internalId = idToInternalId.size + 1));\n }\n return internalId;\n };\n\n return {\n id: (id) => {\n return getId(id);\n },\n set: (id, def) => {\n defs.set(id, def);\n },\n toConfig: () => {\n return defs.entries().reduce(\n (acc, [key, def]) => {\n acc[key] = { children: def };\n return acc;\n },\n {} as {\n [key: string]: { children: Paragraph[] };\n },\n );\n },\n };\n};\n\ntype ListFormat = {\n format: keyof typeof LevelFormat;\n text: string;\n};\n\ntype NumberingRegistry = {\n createId: () => string;\n getIds: () => string[];\n};\nconst createNumberingRegistry = (): NumberingRegistry => {\n let counter = 1;\n\n const ids: string[] = [];\n\n return {\n createId: () => {\n const id = `${ORDERED_LIST_REF}-${counter++}`;\n ids.push(id);\n return id;\n },\n getIds: () => {\n return ids;\n },\n };\n};\n\nconst composeBuilders = (\n pluginsBuilders: readonly NodeBuilders[],\n defaultBuilders: NodeBuilders,\n): NodeBuilders => {\n return pluginsBuilders.reduceRight<NodeBuilders>((acc, p) => {\n type Key = keyof typeof p;\n for (const [k, cur] of Object.entries(p)) {\n const prev = acc[k as Key];\n acc[k as Key] = (\n prev\n ? (n, c) => {\n const r = cur(n as any, c);\n if (r) {\n return r;\n }\n return prev(n as any, c);\n }\n : cur\n ) as NodeBuilder<any>;\n }\n return acc;\n }, defaultBuilders);\n};\n\nconst buildLevels = (formats: readonly ListFormat[]): ILevelsOptions[] => {\n const INDENT_UNIT = 10 * 40;\n return formats.map(({ format, text }, i) => {\n return {\n level: i,\n format: LevelFormat[format],\n text: text,\n alignment: AlignmentType.LEFT,\n style: {\n paragraph: {\n indent: { hanging: INDENT_UNIT, left: INDENT_UNIT * (i + 1) },\n },\n },\n };\n });\n};\n\nexport interface DocxOptions extends Pick<\n IPropertiesOptions,\n | \"title\"\n | \"subject\"\n | \"creator\"\n | \"keywords\"\n | \"description\"\n | \"styles\"\n | \"background\"\n> {\n /**\n * Page size defined in twip (1 twip == 1/1440 inch).\n * @default A4 ({@link sectionPageSizeDefaults})\n */\n size?: { width?: number; height?: number };\n /**\n * Page margin defined in twip (1 twip == 1/1440 inch).\n * @default 1 inch ({@link sectionMarginDefaults})\n */\n margin?: { top?: number; left?: number; bottom?: number; right?: number };\n /**\n * An option to override the text format of ordered list.\n * See https://docx.js.org/#/usage/numbering?id=level-options for more details.\n */\n orderedListFormat?: ListFormat[];\n /**\n * An option to select how thematicBreak works. \"page\" is Page Break. \"section\" is Section Break.\n * @default \"page\"\n */\n thematicBreak?: ThematicBreakType;\n /**\n * Plugins to customize how mdast nodes are compiled.\n */\n plugins?: RemarkDocxPlugin[];\n}\n\nexport const mdastToDocx = async (\n node: mdast.Root,\n {\n plugins = [],\n title,\n subject,\n creator,\n keywords,\n description,\n styles,\n size,\n margin,\n background,\n thematicBreak = \"page\",\n orderedListFormat,\n }: DocxOptions = {},\n): Promise<ArrayBuffer> => {\n const definition = definitions(node);\n\n const numbering = createNumberingRegistry();\n const footnote = createFootnoteRegistry();\n\n const pluginCtx = { root: node, definition };\n\n const builders = composeBuilders(\n await Promise.all(plugins.map((p) => p(pluginCtx))),\n {\n paragraph: buildParagraph,\n heading: buildHeading,\n thematicBreak: buildThematicBreak,\n blockquote: buildBlockquote,\n list: buildList,\n listItem: buildListItem,\n table: buildTable,\n tableRow: noop,\n tableCell: noop,\n html: fallbackText,\n code: fallbackText,\n definition: noop,\n footnoteDefinition: buildFootnoteDefinition,\n text: buildText,\n emphasis: buildEmphasis,\n strong: buildStrong,\n delete: buildDelete,\n inlineCode: buildInlineCode,\n break: buildBreak,\n link: buildLink,\n linkReference: buildLinkReference,\n // image: warnImage,\n // imageReference: warnImage,\n footnoteReference: buildFootnoteReference,\n math: fallbackText,\n inlineMath: fallbackText,\n },\n );\n\n const renderNode = (\n node: mdast.RootContent,\n c: Context,\n ): DocxContent[] | null => {\n const builder = builders[node.type];\n if (!builder) {\n warnOnce(`${node.type} node is not supported without plugins.`);\n return null;\n }\n const r = builder(node as any, c);\n if (r) {\n if (Array.isArray(r)) {\n return r;\n } else {\n return [r];\n }\n }\n return null;\n };\n\n let { WIDTH: pageWidth, HEIGHT: pageHeight } = sectionPageSizeDefaults;\n if (size) {\n if (size.width != null) {\n pageWidth = size.width;\n }\n if (size.height != null) {\n pageHeight = size.height;\n }\n }\n let {\n TOP: marginTop,\n LEFT: marginLeft,\n BOTTOM: marginBottom,\n RIGHT: marginRight,\n } = sectionMarginDefaults;\n if (margin) {\n if (margin.top != null) {\n marginTop = margin.top;\n }\n if (margin.left != null) {\n marginLeft = margin.left;\n }\n if (margin.bottom != null) {\n marginBottom = margin.bottom;\n }\n if (margin.right != null) {\n marginRight = margin.right;\n }\n }\n\n const ctx: Context = {\n render(nodes, c) {\n const results: DocxContent[] = [];\n for (const node of nodes) {\n const r = renderNode(node, c ?? this);\n if (r) {\n results.push(...r);\n }\n }\n return results;\n },\n width: pageWidth - marginLeft - marginRight,\n deco: {},\n indent: 0,\n thematicBreak,\n definition: definition,\n footnote,\n orderedId: numbering.createId,\n };\n\n const sections: DocxContent[][] = [[]];\n for (const n of node.children) {\n const r = renderNode(n, ctx);\n if (r) {\n if (!r.length) {\n // thematicBreak\n sections.push([]);\n } else {\n const lastSection = sections[sections.length - 1]!;\n lastSection.push(...r);\n }\n }\n }\n\n const orderedLevels = buildLevels(\n orderedListFormat ?? [\n { text: \"%1.\", format: \"DECIMAL\" },\n { text: \"%2.\", format: \"DECIMAL\" },\n { text: \"%3.\", format: \"DECIMAL\" },\n { text: \"%4.\", format: \"DECIMAL\" },\n { text: \"%5.\", format: \"DECIMAL\" },\n { text: \"%6.\", format: \"DECIMAL\" },\n ],\n );\n\n const sectionProperties: ISectionPropertiesOptions = {\n page: {\n size: { width: pageWidth, height: pageHeight },\n margin: {\n top: marginTop,\n left: marginLeft,\n bottom: marginBottom,\n right: marginRight,\n },\n },\n };\n\n const doc = new Document({\n title,\n subject,\n creator,\n keywords,\n description,\n styles: styles,\n background,\n sections: sections\n .filter((s) => s.length)\n .map((s) => ({\n properties: sectionProperties,\n children: s as DocxChild[],\n })),\n footnotes: footnote.toConfig(),\n numbering: {\n config: [\n {\n reference: BULLET_LIST_REF,\n levels: buildLevels([\n { text: \"\\u25CF\", format: \"BULLET\" },\n { text: \"\\u25CB\", format: \"BULLET\" },\n { text: \"\\u25A0\", format: \"BULLET\" },\n { text: \"\\u25CF\", format: \"BULLET\" },\n { text: \"\\u25CB\", format: \"BULLET\" },\n { text: \"\\u25A0\", format: \"BULLET\" },\n ]),\n },\n ...numbering.getIds().map((ref) => ({\n reference: ref,\n levels: orderedLevels,\n })),\n {\n reference: COMPLETE_TASK_LIST_REF,\n levels: buildLevels([\n { text: \"\\u2611\", format: \"BULLET\" },\n { text: \"\\u2611\", format: \"BULLET\" },\n { text: \"\\u2611\", format: \"BULLET\" },\n { text: \"\\u2611\", format: \"BULLET\" },\n { text: \"\\u2611\", format: \"BULLET\" },\n { text: \"\\u2611\", format: \"BULLET\" },\n ]),\n },\n {\n reference: INCOMPLETE_TASK_LIST_REF,\n levels: buildLevels([\n { text: \"\\u2610\", format: \"BULLET\" },\n { text: \"\\u2610\", format: \"BULLET\" },\n { text: \"\\u2610\", format: \"BULLET\" },\n { text: \"\\u2610\", format: \"BULLET\" },\n { text: \"\\u2610\", format: \"BULLET\" },\n { text: \"\\u2610\", format: \"BULLET\" },\n ]),\n },\n ],\n },\n });\n\n // HACK: docx.js has no way to remove default numberings styles from .docx. So do it here for now.\n // https://github.com/dolanmiu/docx/blob/master/src/file/numbering/numbering.ts\n const defaultBulletKey = \"default-bullet-numbering\";\n const _numbering = (doc as any).numbering;\n _numbering.abstractNumberingMap.delete(defaultBulletKey);\n _numbering.concreteNumberingMap.delete(defaultBulletKey);\n\n return Packer.toArrayBuffer(doc);\n};\n\nconst buildParagraph: NodeBuilder<\"paragraph\"> = ({ children }, ctx) => {\n const list = ctx.list;\n const nodes = ctx.render(children);\n\n const options: Writeable<IParagraphOptions> = {\n children: nodes,\n };\n\n if (ctx.indent > 0) {\n options.indent = {\n start: convertInchesToTwip(INDENT * ctx.indent),\n };\n }\n\n if (list) {\n const { level, meta } = list;\n if (meta.type === \"task\") {\n options.numbering = {\n reference: meta.checked\n ? COMPLETE_TASK_LIST_REF\n : INCOMPLETE_TASK_LIST_REF,\n level,\n };\n } else if (meta.type === \"ordered\") {\n options.numbering = {\n reference: meta.reference,\n level,\n };\n } else {\n options.numbering = {\n reference: BULLET_LIST_REF,\n level,\n };\n }\n }\n\n return new Paragraph(options);\n};\n\nconst buildHeading: NodeBuilder<\"heading\"> = ({ children, depth }, ctx) => {\n let level: keyof typeof HeadingLevel;\n switch (depth) {\n case 1:\n level = \"TITLE\";\n break;\n case 2:\n level = \"HEADING_1\";\n break;\n case 3:\n level = \"HEADING_2\";\n break;\n case 4:\n level = \"HEADING_3\";\n break;\n case 5:\n level = \"HEADING_4\";\n break;\n case 6:\n level = \"HEADING_5\";\n break;\n }\n return new Paragraph({\n heading: HeadingLevel[level],\n children: ctx.render(children),\n });\n};\n\nconst buildThematicBreak: NodeBuilder<\"thematicBreak\"> = (_, ctx) => {\n if (ctx.thematicBreak === \"section\") {\n // Returning empty array at toplevel means section insertion.\n return [];\n }\n return new Paragraph({ children: [new PageBreak()] });\n};\n\nconst buildBlockquote: NodeBuilder<\"blockquote\"> = ({ children }, ctx) => {\n return ctx.render(children, {\n ...ctx,\n indent: ctx.indent + 1,\n });\n};\n\nconst buildList: NodeBuilder<\"list\"> = ({ children, ordered }, ctx) => {\n const parentList = ctx.list;\n\n let meta: ListContext[\"meta\"];\n if (ordered) {\n meta = {\n type: \"ordered\",\n reference:\n parentList && parentList.meta.type === \"ordered\"\n ? parentList.meta.reference\n : ctx.orderedId(),\n };\n } else {\n meta = { type: \"bullet\" };\n }\n\n return ctx.render(children, {\n ...ctx,\n list: {\n level: !parentList ? 0 : parentList.level + 1,\n meta,\n },\n });\n};\n\nconst buildListItem: NodeBuilder<\"listItem\"> = ({ children, checked }, ctx) => {\n let list = ctx.list;\n if (list) {\n // listItem must be the child of list\n if (checked != null) {\n list = {\n level: list.level,\n meta: {\n type: \"task\",\n checked,\n },\n };\n }\n }\n return ctx.render(children, {\n ...ctx,\n list,\n });\n};\n\nconst buildTable: NodeBuilder<\"table\"> = ({ children, align }, ctx) => {\n const textAlign = align?.map((a): keyof typeof AlignmentType => {\n switch (a) {\n case \"left\":\n return \"LEFT\";\n case \"right\":\n return \"RIGHT\";\n case \"center\":\n return \"CENTER\";\n default:\n return \"LEFT\";\n }\n });\n\n const columnLength = children[0]!.children.length;\n const columnWidth = ctx.width / columnLength;\n\n return new Table({\n columnWidths: Array.from({ length: columnLength }).map(() => columnWidth),\n rows: children.map((r) => {\n return new TableRow({\n children: r.children.map((c, i) => {\n return new TableCell({\n width: { size: columnWidth, type: \"dxa\" },\n children: [\n new Paragraph({\n alignment: AlignmentType[textAlign?.[i] ?? \"LEFT\"],\n children: ctx.render(c.children),\n }),\n ],\n });\n }),\n });\n }),\n });\n};\n\nconst buildText: NodeBuilder<\"text\"> = ({ value }, { deco }) => {\n const options: Writeable<IRunOptions> = {\n text: value,\n bold: deco.bold,\n italics: deco.italic,\n strike: deco.strike,\n };\n if (deco.inlineCode) {\n options.highlight = \"lightGray\";\n }\n if (deco.link) {\n // https://docx.js.org/#/usage/hyperlinks?id=styling-hyperlinks\n options.style = HYPERLINK_STYLE_ID;\n }\n return new TextRun(options);\n};\n\nconst buildEmphasis: NodeBuilder<\"emphasis\"> = ({ children }, ctx) => {\n return ctx.render(children, {\n ...ctx,\n deco: { ...ctx.deco, italic: true },\n });\n};\n\nconst buildStrong: NodeBuilder<\"strong\"> = ({ children }, ctx) => {\n return ctx.render(children, {\n ...ctx,\n deco: { ...ctx.deco, bold: true },\n });\n};\n\nconst buildDelete: NodeBuilder<\"delete\"> = ({ children }, ctx) => {\n return ctx.render(children, {\n ...ctx,\n deco: { ...ctx.deco, strike: true },\n });\n};\n\nconst buildInlineCode: NodeBuilder<\"inlineCode\"> = ({ value }, ctx) => {\n return buildText(\n { type: \"text\", value },\n {\n ...ctx,\n deco: { ...ctx.deco, inlineCode: true },\n },\n );\n};\n\nconst buildBreak: NodeBuilder<\"break\"> = () => {\n return new TextRun({ text: \"\", break: 1 });\n};\n\nconst buildLink: NodeBuilder<\"link\"> = ({ children, url }, ctx) => {\n if (url.startsWith(\"#\")) {\n // TODO support anchor link\n return ctx.render(children);\n }\n return new ExternalHyperlink({\n link: url,\n children: ctx.render(children, {\n ...ctx,\n deco: { ...ctx.deco, link: true },\n }),\n });\n};\n\nconst buildLinkReference: NodeBuilder<\"linkReference\"> = (\n { children, identifier },\n ctx,\n) => {\n const def = ctx.definition(identifier);\n if (def == null) {\n return ctx.render(children);\n }\n return buildLink({ type: \"link\", children, url: def.url }, ctx);\n};\n\nconst buildFootnoteDefinition: NodeBuilder<\"footnoteDefinition\"> = (\n { children, identifier },\n ctx,\n) => {\n const contents = ctx.render(children).filter((c) => c instanceof Paragraph);\n ctx.footnote.set(ctx.footnote.id(identifier), contents);\n return null;\n};\n\nconst buildFootnoteReference: NodeBuilder<\"footnoteReference\"> = (\n { identifier },\n ctx,\n) => {\n return new FootnoteReferenceRun(ctx.footnote.id(identifier));\n};\n\nconst noop = () => {\n return null;\n};\n\nconst fallbackText = (node: { type: string; value: string }, ctx: Context) => {\n warnOnce(\n `${node.type} node is not supported without plugins, falling back to text.`,\n );\n return buildText({ type: \"text\", value: node.value }, ctx);\n};\n","import type { Plugin } from \"unified\";\nimport type { Root } from \"mdast\";\nimport { mdastToDocx, type DocxOptions } from \"./mdast-util-to-docx\";\n\nexport type { DocxOptions };\n\ndeclare module \"unified\" {\n interface CompileResultMap {\n docx: Promise<ArrayBuffer>;\n }\n}\n\nconst plugin: Plugin<[DocxOptions?], Root, Promise<ArrayBuffer>> = function (\n opts,\n) {\n this.compiler = (node) => {\n return mdastToDocx(node as Root, opts);\n };\n};\nexport default plugin;\n"],"names":["LevelFormat","AlignmentType","definitions","sectionPageSizeDefaults","sectionMarginDefaults","Document","Packer","convertInchesToTwip","Paragraph","HeadingLevel","PageBreak","Table","TableRow","TableCell","TextRun","ExternalHyperlink","FootnoteReferenceRun"],"mappings":";;;;;AAAA,MAAM,aAAa,GAAmC,EAAE;AAExD;;AAEG;SACa,QAAQ,CAAC,OAAe,EAAE,OAAgB,KAAK,EAAA;IAC7D,IAAI,CAAC,IAAI,IAAI,CAAC,aAAa,CAAC,OAAO,CAAC,EAAE;AACpC,QAAA,aAAa,CAAC,OAAO,CAAC,GAAG,IAAI;AAC7B,QAAA,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC;IACvB;AACF;;AC6BA,MAAM,eAAe,GAAG,QAAQ;AAChC,MAAM,gBAAgB,GAAG,SAAS;AAClC,MAAM,sBAAsB,GAAG,eAAe;AAC9C,MAAM,wBAAwB,GAAG,iBAAiB;AAClD,MAAM,kBAAkB,GAAG,WAAW;AACtC,MAAM,MAAM,GAAG,GAAG;AAElB,MAAM,sBAAsB,GAAG,MAAuB;AACpD,IAAA,MAAM,cAAc,GAAG,IAAI,GAAG,EAAkB;AAChD,IAAA,MAAM,IAAI,GAAG,IAAI,GAAG,EAAuB;AAE3C,IAAA,MAAM,KAAK,GAAG,CAAC,EAAU,KAAY;QACnC,IAAI,UAAU,GAAG,cAAc,CAAC,GAAG,CAAC,EAAE,CAAC;AACvC,QAAA,IAAI,UAAU,IAAI,IAAI,EAAE;AACtB,YAAA,cAAc,CAAC,GAAG,CAAC,EAAE,GAAG,UAAU,GAAG,cAAc,CAAC,IAAI,GAAG,CAAC,EAAE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