remark-docx 0.3.9 → 0.3.11
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/lib/index.cjs +137 -168
- package/lib/index.cjs.map +1 -1
- package/lib/index.js +137 -168
- package/lib/index.js.map +1 -1
- package/lib/{mdast-to-docx.d.ts → mdast-util-to-docx.d.ts} +3 -3
- package/lib/plugin.d.ts +1 -1
- package/lib/plugins/html/index.cjs +2 -2
- package/lib/plugins/html/index.cjs.map +1 -1
- package/lib/plugins/html/index.js +2 -2
- package/lib/plugins/html/index.js.map +1 -1
- package/lib/plugins/image/index.cjs +17 -7
- package/lib/plugins/image/index.cjs.map +1 -1
- package/lib/plugins/image/index.js +14 -4
- package/lib/plugins/image/index.js.map +1 -1
- package/lib/plugins/math/index.cjs +4 -2
- package/lib/plugins/math/index.cjs.map +1 -1
- package/lib/plugins/math/index.js +3 -1
- package/lib/plugins/math/index.js.map +1 -1
- package/lib/types.d.ts +25 -5
- package/package.json +2 -1
- package/lib/mdast.d.ts +0 -2
- package/lib/utils-40yKzkXT.js +0 -19
- package/lib/utils-40yKzkXT.js.map +0 -1
- package/lib/utils-EYEfXxbh.js +0 -22
- package/lib/utils-EYEfXxbh.js.map +0 -1
package/lib/index.cjs
CHANGED
|
@@ -3,12 +3,6 @@
|
|
|
3
3
|
var docx = require('docx');
|
|
4
4
|
var mdastUtilDefinitions = require('mdast-util-definitions');
|
|
5
5
|
|
|
6
|
-
/**
|
|
7
|
-
* @internal
|
|
8
|
-
*/
|
|
9
|
-
function invariant(cond, message) {
|
|
10
|
-
throw new Error(message);
|
|
11
|
-
}
|
|
12
6
|
const alreadyWarned = {};
|
|
13
7
|
/**
|
|
14
8
|
* @internal
|
|
@@ -45,7 +39,7 @@ const createFootnoteRegistry = () => {
|
|
|
45
39
|
},
|
|
46
40
|
toConfig: () => {
|
|
47
41
|
return defs.entries().reduce((acc, [key, def]) => {
|
|
48
|
-
acc[key] = def;
|
|
42
|
+
acc[key] = { children: def };
|
|
49
43
|
return acc;
|
|
50
44
|
}, {});
|
|
51
45
|
},
|
|
@@ -128,19 +122,92 @@ const createNumberingRegistry = () => {
|
|
|
128
122
|
},
|
|
129
123
|
};
|
|
130
124
|
};
|
|
131
|
-
const mdastToDocx = async (node, { plugins = [], title, subject, creator, keywords, description, lastModifiedBy, revision, styles, background, }) => {
|
|
125
|
+
const mdastToDocx = async (node, { plugins = [], title, subject, creator, keywords, description, lastModifiedBy, revision, styles, background, } = {}) => {
|
|
132
126
|
const definition = mdastUtilDefinitions.definitions(node);
|
|
133
127
|
const footnote = createFootnoteRegistry();
|
|
134
128
|
const numbering = createNumberingRegistry();
|
|
135
129
|
const pluginCtx = { root: node, definition };
|
|
136
|
-
const
|
|
137
|
-
|
|
130
|
+
const builders = (await Promise.all(plugins.map((p) => p(pluginCtx)))).reduceRight((acc, p) => {
|
|
131
|
+
for (const k of Object.keys(p)) {
|
|
132
|
+
acc[k] = p[k];
|
|
133
|
+
}
|
|
134
|
+
return acc;
|
|
135
|
+
}, {
|
|
136
|
+
paragraph: buildParagraph,
|
|
137
|
+
heading: buildHeading,
|
|
138
|
+
thematicBreak: buildThematicBreak,
|
|
139
|
+
blockquote: buildBlockquote,
|
|
140
|
+
list: buildList,
|
|
141
|
+
listItem: buildListItem,
|
|
142
|
+
table: buildTable,
|
|
143
|
+
tableRow: noop,
|
|
144
|
+
tableCell: noop,
|
|
145
|
+
html: fallbackText,
|
|
146
|
+
code: fallbackText,
|
|
147
|
+
definition: noop,
|
|
148
|
+
footnoteDefinition: buildFootnoteDefinition,
|
|
149
|
+
text: buildText,
|
|
150
|
+
emphasis: buildEmphasis,
|
|
151
|
+
strong: buildStrong,
|
|
152
|
+
delete: buildDelete,
|
|
153
|
+
inlineCode: buildInlineCode,
|
|
154
|
+
break: buildBreak,
|
|
155
|
+
link: buildLink,
|
|
156
|
+
linkReference: buildLinkReference,
|
|
157
|
+
// image: warnImage,
|
|
158
|
+
// imageReference: warnImage,
|
|
159
|
+
footnoteReference: buildFootnoteReference,
|
|
160
|
+
math: fallbackText,
|
|
161
|
+
inlineMath: fallbackText,
|
|
162
|
+
});
|
|
163
|
+
const renderNode = (node, c) => {
|
|
164
|
+
const builder = builders[node.type];
|
|
165
|
+
if (!builder) {
|
|
166
|
+
warnOnce(`${node.type} node is not supported without plugins.`);
|
|
167
|
+
return null;
|
|
168
|
+
}
|
|
169
|
+
const r = builder(node, c);
|
|
170
|
+
if (r) {
|
|
171
|
+
if (Array.isArray(r)) {
|
|
172
|
+
return r;
|
|
173
|
+
}
|
|
174
|
+
else {
|
|
175
|
+
return [r];
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
return null;
|
|
179
|
+
};
|
|
180
|
+
const ctx = {
|
|
181
|
+
render(nodes, c) {
|
|
182
|
+
const results = [];
|
|
183
|
+
for (const node of nodes) {
|
|
184
|
+
const r = renderNode(node, c !== null && c !== void 0 ? c : this);
|
|
185
|
+
if (r) {
|
|
186
|
+
results.push(...r);
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
return results;
|
|
190
|
+
},
|
|
138
191
|
deco: {},
|
|
139
192
|
indent: 0,
|
|
140
193
|
definition: definition,
|
|
141
194
|
footnote,
|
|
142
195
|
numbering,
|
|
143
|
-
}
|
|
196
|
+
};
|
|
197
|
+
const sections = [[]];
|
|
198
|
+
for (const n of node.children) {
|
|
199
|
+
const r = renderNode(n, ctx);
|
|
200
|
+
if (r) {
|
|
201
|
+
if (!r.length) {
|
|
202
|
+
// thematicBreak
|
|
203
|
+
sections.push([]);
|
|
204
|
+
}
|
|
205
|
+
else {
|
|
206
|
+
const lastSection = sections[sections.length - 1];
|
|
207
|
+
lastSection.push(...r);
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
}
|
|
144
211
|
const doc = new docx.Document({
|
|
145
212
|
title,
|
|
146
213
|
subject,
|
|
@@ -151,129 +218,19 @@ const mdastToDocx = async (node, { plugins = [], title, subject, creator, keywor
|
|
|
151
218
|
revision,
|
|
152
219
|
styles,
|
|
153
220
|
background,
|
|
221
|
+
sections: sections
|
|
222
|
+
.filter((s) => s.length)
|
|
223
|
+
.map((s) => ({ children: s })),
|
|
154
224
|
footnotes: footnote.toConfig(),
|
|
155
|
-
sections: [{ children: nodes }],
|
|
156
225
|
numbering: {
|
|
157
226
|
config: numbering.toConfig(),
|
|
158
227
|
},
|
|
159
228
|
});
|
|
160
229
|
return docx.Packer.toArrayBuffer(doc);
|
|
161
230
|
};
|
|
162
|
-
const convertNodes = (nodes, ctx) => {
|
|
163
|
-
var _a, _b;
|
|
164
|
-
const results = [];
|
|
165
|
-
for (const node of nodes) {
|
|
166
|
-
const customNodes = (_b = (_a = ctx.overrides)[node.type]) === null || _b === void 0 ? void 0 : _b.call(_a, node, (children) => convertNodes(children, ctx));
|
|
167
|
-
if (customNodes != null) {
|
|
168
|
-
if (Array.isArray(customNodes)) {
|
|
169
|
-
results.push(...customNodes);
|
|
170
|
-
}
|
|
171
|
-
else {
|
|
172
|
-
results.push(customNodes);
|
|
173
|
-
}
|
|
174
|
-
continue;
|
|
175
|
-
}
|
|
176
|
-
switch (node.type) {
|
|
177
|
-
case "paragraph": {
|
|
178
|
-
results.push(buildParagraph(node, ctx));
|
|
179
|
-
break;
|
|
180
|
-
}
|
|
181
|
-
case "heading": {
|
|
182
|
-
results.push(buildHeading(node, ctx));
|
|
183
|
-
break;
|
|
184
|
-
}
|
|
185
|
-
case "thematicBreak":
|
|
186
|
-
results.push(buildThematicBreak());
|
|
187
|
-
break;
|
|
188
|
-
case "blockquote": {
|
|
189
|
-
results.push(...buildBlockquote(node, ctx));
|
|
190
|
-
break;
|
|
191
|
-
}
|
|
192
|
-
case "list": {
|
|
193
|
-
results.push(...buildList(node, ctx));
|
|
194
|
-
break;
|
|
195
|
-
}
|
|
196
|
-
case "listItem":
|
|
197
|
-
invariant(false, "unreachable");
|
|
198
|
-
case "table":
|
|
199
|
-
results.push(buildTable(node, ctx));
|
|
200
|
-
break;
|
|
201
|
-
case "tableRow":
|
|
202
|
-
invariant(false, "unreachable");
|
|
203
|
-
case "tableCell":
|
|
204
|
-
invariant(false, "unreachable");
|
|
205
|
-
case "html":
|
|
206
|
-
warnOnce(`${node.type} node is not rendered since remark-docx/plugins/html is not provided.`);
|
|
207
|
-
break;
|
|
208
|
-
case "code":
|
|
209
|
-
warnOnce(`${node.type} node is not rendered since remark-docx/plugins/code is not provided.`);
|
|
210
|
-
break;
|
|
211
|
-
// case "yaml":
|
|
212
|
-
// // unimplemented
|
|
213
|
-
// break;
|
|
214
|
-
// case "toml":
|
|
215
|
-
// // unimplemented
|
|
216
|
-
// break;
|
|
217
|
-
case "definition":
|
|
218
|
-
// noop
|
|
219
|
-
break;
|
|
220
|
-
case "footnoteDefinition": {
|
|
221
|
-
registerFootnoteDefinition(node, ctx);
|
|
222
|
-
break;
|
|
223
|
-
}
|
|
224
|
-
case "text":
|
|
225
|
-
results.push(buildText(node.value, ctx.deco));
|
|
226
|
-
break;
|
|
227
|
-
case "emphasis":
|
|
228
|
-
case "strong":
|
|
229
|
-
case "delete": {
|
|
230
|
-
const { type, children } = node;
|
|
231
|
-
const nodes = convertNodes(children, {
|
|
232
|
-
...ctx,
|
|
233
|
-
deco: { ...ctx.deco, [type]: true },
|
|
234
|
-
});
|
|
235
|
-
results.push(...nodes);
|
|
236
|
-
break;
|
|
237
|
-
}
|
|
238
|
-
case "inlineCode":
|
|
239
|
-
results.push(buildInlineCode(node));
|
|
240
|
-
break;
|
|
241
|
-
case "break":
|
|
242
|
-
results.push(buildBreak());
|
|
243
|
-
break;
|
|
244
|
-
case "link": {
|
|
245
|
-
results.push(buildLink(node, ctx));
|
|
246
|
-
break;
|
|
247
|
-
}
|
|
248
|
-
case "linkReference":
|
|
249
|
-
results.push(...buildLinkReference(node, ctx));
|
|
250
|
-
break;
|
|
251
|
-
case "image":
|
|
252
|
-
case "imageReference": {
|
|
253
|
-
warnOnce(`${node.type} node is not rendered since remark-docx/plugins/image is not provided.`);
|
|
254
|
-
break;
|
|
255
|
-
}
|
|
256
|
-
// case "footnote": {
|
|
257
|
-
// // inline footnote was removed in mdast v5
|
|
258
|
-
// break;
|
|
259
|
-
// }
|
|
260
|
-
case "footnoteReference":
|
|
261
|
-
results.push(buildFootnoteReference(node, ctx));
|
|
262
|
-
break;
|
|
263
|
-
case "math":
|
|
264
|
-
case "inlineMath":
|
|
265
|
-
warnOnce(`${node.type} node is not rendered since remark-docx/plugins/math is not provided.`);
|
|
266
|
-
break;
|
|
267
|
-
default:
|
|
268
|
-
warnOnce(`${node.type} node is not officially supported.`);
|
|
269
|
-
break;
|
|
270
|
-
}
|
|
271
|
-
}
|
|
272
|
-
return results;
|
|
273
|
-
};
|
|
274
231
|
const buildParagraph = ({ children }, ctx) => {
|
|
275
232
|
const list = ctx.list;
|
|
276
|
-
const nodes =
|
|
233
|
+
const nodes = ctx.render(children);
|
|
277
234
|
if (list && list.checked != null) {
|
|
278
235
|
nodes.unshift(new docx.CheckBox({
|
|
279
236
|
checked: list.checked,
|
|
@@ -325,19 +282,18 @@ const buildHeading = ({ children, depth }, ctx) => {
|
|
|
325
282
|
headingLevel = docx.HeadingLevel.HEADING_5;
|
|
326
283
|
break;
|
|
327
284
|
}
|
|
328
|
-
const nodes =
|
|
285
|
+
const nodes = ctx.render(children);
|
|
329
286
|
return new docx.Paragraph({
|
|
330
287
|
heading: headingLevel,
|
|
331
288
|
children: nodes,
|
|
332
289
|
});
|
|
333
290
|
};
|
|
334
|
-
const buildThematicBreak = (
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
});
|
|
291
|
+
const buildThematicBreak = () => {
|
|
292
|
+
// Returning empty array at toplevel means section insertion.
|
|
293
|
+
return [];
|
|
338
294
|
};
|
|
339
295
|
const buildBlockquote = ({ children }, ctx) => {
|
|
340
|
-
return
|
|
296
|
+
return ctx.render(children, {
|
|
341
297
|
...ctx,
|
|
342
298
|
indent: ctx.indent + 1,
|
|
343
299
|
});
|
|
@@ -345,22 +301,20 @@ const buildBlockquote = ({ children }, ctx) => {
|
|
|
345
301
|
const buildList = ({ children, ordered }, ctx) => {
|
|
346
302
|
var _a;
|
|
347
303
|
const isTopLevel = !ctx.list;
|
|
348
|
-
const
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
list,
|
|
359
|
-
});
|
|
304
|
+
const reference = isTopLevel && ordered
|
|
305
|
+
? ctx.numbering.create()
|
|
306
|
+
: ((_a = ctx.list) === null || _a === void 0 ? void 0 : _a.reference) || ORDERED_LIST_REF;
|
|
307
|
+
return ctx.render(children, {
|
|
308
|
+
...ctx,
|
|
309
|
+
list: {
|
|
310
|
+
level: isTopLevel ? 0 : ctx.list.level + 1,
|
|
311
|
+
ordered: !!ordered,
|
|
312
|
+
reference,
|
|
313
|
+
},
|
|
360
314
|
});
|
|
361
315
|
};
|
|
362
316
|
const buildListItem = ({ children, checked }, ctx) => {
|
|
363
|
-
return
|
|
317
|
+
return ctx.render(children, {
|
|
364
318
|
...ctx,
|
|
365
319
|
...(ctx.list && { list: { ...ctx.list, checked: checked !== null && checked !== void 0 ? checked : undefined } }),
|
|
366
320
|
});
|
|
@@ -390,7 +344,7 @@ const buildTable = ({ children, align }, ctx) => {
|
|
|
390
344
|
children: [
|
|
391
345
|
new docx.Paragraph({
|
|
392
346
|
alignment: cellAligns === null || cellAligns === void 0 ? void 0 : cellAligns[i],
|
|
393
|
-
children:
|
|
347
|
+
children: ctx.render(c.children),
|
|
394
348
|
}),
|
|
395
349
|
],
|
|
396
350
|
});
|
|
@@ -399,12 +353,30 @@ const buildTable = ({ children, align }, ctx) => {
|
|
|
399
353
|
}),
|
|
400
354
|
});
|
|
401
355
|
};
|
|
402
|
-
const buildText = (
|
|
356
|
+
const buildText = ({ value }, { deco }) => {
|
|
403
357
|
return new docx.TextRun({
|
|
404
|
-
text,
|
|
405
|
-
bold: deco.
|
|
406
|
-
italics: deco.
|
|
407
|
-
strike: deco.
|
|
358
|
+
text: value,
|
|
359
|
+
bold: deco.bold,
|
|
360
|
+
italics: deco.italic,
|
|
361
|
+
strike: deco.strike,
|
|
362
|
+
});
|
|
363
|
+
};
|
|
364
|
+
const buildEmphasis = ({ children }, ctx) => {
|
|
365
|
+
return ctx.render(children, {
|
|
366
|
+
...ctx,
|
|
367
|
+
deco: { ...ctx.deco, italic: true },
|
|
368
|
+
});
|
|
369
|
+
};
|
|
370
|
+
const buildStrong = ({ children }, ctx) => {
|
|
371
|
+
return ctx.render(children, {
|
|
372
|
+
...ctx,
|
|
373
|
+
deco: { ...ctx.deco, bold: true },
|
|
374
|
+
});
|
|
375
|
+
};
|
|
376
|
+
const buildDelete = ({ children }, ctx) => {
|
|
377
|
+
return ctx.render(children, {
|
|
378
|
+
...ctx,
|
|
379
|
+
deco: { ...ctx.deco, strike: true },
|
|
408
380
|
});
|
|
409
381
|
};
|
|
410
382
|
const buildInlineCode = ({ value }) => {
|
|
@@ -413,11 +385,11 @@ const buildInlineCode = ({ value }) => {
|
|
|
413
385
|
highlight: "lightGray",
|
|
414
386
|
});
|
|
415
387
|
};
|
|
416
|
-
const buildBreak = (
|
|
388
|
+
const buildBreak = () => {
|
|
417
389
|
return new docx.TextRun({ text: "", break: 1 });
|
|
418
390
|
};
|
|
419
391
|
const buildLink = ({ children, url }, ctx) => {
|
|
420
|
-
const nodes =
|
|
392
|
+
const nodes = ctx.render(children);
|
|
421
393
|
return new docx.ExternalHyperlink({
|
|
422
394
|
link: url,
|
|
423
395
|
children: nodes,
|
|
@@ -426,29 +398,26 @@ const buildLink = ({ children, url }, ctx) => {
|
|
|
426
398
|
const buildLinkReference = ({ children, identifier }, ctx) => {
|
|
427
399
|
const def = ctx.definition(identifier);
|
|
428
400
|
if (def == null) {
|
|
429
|
-
return
|
|
401
|
+
return ctx.render(children);
|
|
430
402
|
}
|
|
431
|
-
return
|
|
403
|
+
return buildLink({ children, url: def.url }, ctx);
|
|
432
404
|
};
|
|
433
|
-
const
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
// Convert each node and extract the first result as a paragraph
|
|
437
|
-
const nodes = convertNodes([node], ctx);
|
|
438
|
-
if (nodes[0] instanceof docx.Paragraph) {
|
|
439
|
-
return nodes[0];
|
|
440
|
-
}
|
|
441
|
-
// For non-paragraph content, wrap in a paragraph
|
|
442
|
-
return new docx.Paragraph({ children: nodes });
|
|
443
|
-
}),
|
|
444
|
-
};
|
|
445
|
-
ctx.footnote.def(identifier, definition);
|
|
405
|
+
const buildFootnoteDefinition = ({ children, identifier }, ctx) => {
|
|
406
|
+
ctx.footnote.def(identifier, ctx.render(children).filter((c) => c instanceof docx.Paragraph));
|
|
407
|
+
return null;
|
|
446
408
|
};
|
|
447
409
|
const buildFootnoteReference = ({ identifier }, ctx) => {
|
|
448
410
|
return new docx.FootnoteReferenceRun(ctx.footnote.ref(identifier));
|
|
449
411
|
};
|
|
412
|
+
const noop = () => {
|
|
413
|
+
return null;
|
|
414
|
+
};
|
|
415
|
+
const fallbackText = (node, ctx) => {
|
|
416
|
+
warnOnce(`${node.type} node is not supported without plugins, falling back to text.`);
|
|
417
|
+
return buildText({ value: node.value }, ctx);
|
|
418
|
+
};
|
|
450
419
|
|
|
451
|
-
const plugin = function (opts
|
|
420
|
+
const plugin = function (opts) {
|
|
452
421
|
this.compiler = (node) => {
|
|
453
422
|
return mdastToDocx(node, opts);
|
|
454
423
|
};
|
package/lib/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","sources":["../src/src/utils.ts","../src/src/mdast-to-docx.ts","../src/src/plugin.ts"],"sourcesContent":["/**\n * @internal\n */\nexport function invariant(cond: any, message: string): asserts cond {\n if (!cond) throw new Error(message);\n}\n\nconst 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} from \"docx\";\nimport type * as mdast from \"./mdast\";\nimport { invariant, warnOnce } from \"./utils\";\nimport { definitions, type GetDefinition } from \"mdast-util-definitions\";\nimport type {\n DocxChild,\n DocxContent,\n NodeOverrides,\n RemarkDocxPlugin,\n} from \"./types\";\n\nconst CONTENT_WIDTH =\n sectionPageSizeDefaults.WIDTH -\n sectionMarginDefaults.LEFT -\n sectionMarginDefaults.RIGHT;\nconst ORDERED_LIST_REF = \"ordered\";\nconst INDENT = 0.5;\n\ntype Decoration = Readonly<{\n [key in (mdast.Emphasis | mdast.Strong | mdast.Delete)[\"type\"]]?: true;\n}>;\n\ntype ListInfo = Readonly<{\n level: number;\n ordered: boolean;\n reference: string;\n checked?: boolean;\n}>;\n\ntype FootnoteDefinition = Readonly<{ children: Paragraph[] }>;\ntype FootnoteRegistry = {\n ref: (id: string) => number;\n def: (id: string, def: FootnoteDefinition) => void;\n toConfig: () => {\n [key: string]: FootnoteDefinition;\n };\n};\n\nconst createFootnoteRegistry = (): FootnoteRegistry => {\n const idToInternalId = new Map<string, number>();\n const defs = new Map<number, FootnoteDefinition>();\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] = def;\n return acc;\n },\n {} as {\n [key: string]: FootnoteDefinition;\n },\n );\n },\n };\n};\n\ntype NumberingRegistry = {\n create: () => string;\n toConfig: () => Array<{ reference: string; levels: ILevelsOptions[] }>;\n};\n\nconst createNumberingRegistry = (): NumberingRegistry => {\n let counter = 1;\n\n const DEFAULT_NUMBERINGS: ILevelsOptions[] = [\n {\n level: 0,\n format: LevelFormat.DECIMAL,\n text: \"%1.\",\n alignment: AlignmentType.START,\n },\n {\n level: 1,\n format: LevelFormat.DECIMAL,\n text: \"%2.\",\n alignment: AlignmentType.START,\n style: {\n paragraph: {\n indent: { start: convertInchesToTwip(INDENT * 1) },\n },\n },\n },\n {\n level: 2,\n format: LevelFormat.DECIMAL,\n text: \"%3.\",\n alignment: AlignmentType.START,\n style: {\n paragraph: {\n indent: { start: convertInchesToTwip(INDENT * 2) },\n },\n },\n },\n {\n level: 3,\n format: LevelFormat.DECIMAL,\n text: \"%4.\",\n alignment: AlignmentType.START,\n style: {\n paragraph: {\n indent: { start: convertInchesToTwip(INDENT * 3) },\n },\n },\n },\n {\n level: 4,\n format: LevelFormat.DECIMAL,\n text: \"%5.\",\n alignment: AlignmentType.START,\n style: {\n paragraph: {\n indent: { start: convertInchesToTwip(INDENT * 4) },\n },\n },\n },\n {\n level: 5,\n format: LevelFormat.DECIMAL,\n text: \"%6.\",\n alignment: AlignmentType.START,\n style: {\n paragraph: {\n indent: { start: convertInchesToTwip(INDENT * 5) },\n },\n },\n },\n ];\n\n return {\n create: () => {\n return `${ORDERED_LIST_REF}-${counter++}`;\n },\n toConfig: () => {\n return Array.from({ length: counter }, (_, i) => ({\n reference: `${ORDERED_LIST_REF}-${i}`,\n levels: DEFAULT_NUMBERINGS,\n }));\n },\n };\n};\n\ntype Context = Readonly<{\n overrides: NodeOverrides;\n deco: Decoration;\n indent: number;\n list?: ListInfo;\n definition: GetDefinition;\n footnote: FootnoteRegistry;\n numbering: NumberingRegistry;\n}>;\n\nexport interface DocxOptions extends Pick<\n IPropertiesOptions,\n | \"title\"\n | \"subject\"\n | \"creator\"\n | \"keywords\"\n | \"description\"\n | \"lastModifiedBy\"\n | \"revision\"\n | \"styles\"\n | \"background\"\n> {\n /**\n * Plugins to customize how mdast nodes are transformed.\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 lastModifiedBy,\n revision,\n styles,\n background,\n }: DocxOptions,\n): Promise<ArrayBuffer> => {\n const definition = definitions(node);\n\n const footnote = createFootnoteRegistry();\n const numbering = createNumberingRegistry();\n\n const pluginCtx = { root: node, definition };\n const nodes = convertNodes(node.children, {\n overrides: (\n await Promise.all(plugins.map((p) => p(pluginCtx)))\n ).reduceRight((acc, p) => ({ ...acc, ...p }), {}),\n deco: {},\n indent: 0,\n definition: definition,\n footnote,\n numbering,\n });\n\n const doc = new Document({\n title,\n subject,\n creator,\n keywords,\n description,\n lastModifiedBy,\n revision,\n styles,\n background,\n footnotes: footnote.toConfig(),\n sections: [{ children: nodes as DocxChild[] }],\n numbering: {\n config: numbering.toConfig(),\n },\n });\n\n return Packer.toArrayBuffer(doc);\n};\n\nconst convertNodes = (\n nodes: mdast.RootContent[],\n ctx: Context,\n): DocxContent[] => {\n const results: DocxContent[] = [];\n for (const node of nodes) {\n const customNodes = ctx.overrides[node.type]?.(node as any, (children) =>\n convertNodes(children, ctx),\n );\n if (customNodes != null) {\n if (Array.isArray(customNodes)) {\n results.push(...customNodes);\n } else {\n results.push(customNodes);\n }\n continue;\n }\n\n switch (node.type) {\n case \"paragraph\": {\n results.push(buildParagraph(node, ctx));\n break;\n }\n case \"heading\": {\n results.push(buildHeading(node, ctx));\n break;\n }\n case \"thematicBreak\":\n results.push(buildThematicBreak(node));\n break;\n case \"blockquote\": {\n results.push(...buildBlockquote(node, ctx));\n break;\n }\n case \"list\": {\n results.push(...buildList(node, ctx));\n break;\n }\n case \"listItem\":\n invariant(false, \"unreachable\");\n case \"table\":\n results.push(buildTable(node, ctx));\n break;\n case \"tableRow\":\n invariant(false, \"unreachable\");\n case \"tableCell\":\n invariant(false, \"unreachable\");\n case \"html\":\n warnOnce(\n `${node.type} node is not rendered since remark-docx/plugins/html is not provided.`,\n );\n break;\n case \"code\":\n warnOnce(\n `${node.type} node is not rendered since remark-docx/plugins/code is not provided.`,\n );\n break;\n // case \"yaml\":\n // // unimplemented\n // break;\n // case \"toml\":\n // // unimplemented\n // break;\n case \"definition\":\n // noop\n break;\n case \"footnoteDefinition\": {\n registerFootnoteDefinition(node, ctx);\n break;\n }\n case \"text\":\n results.push(buildText(node.value, ctx.deco));\n break;\n case \"emphasis\":\n case \"strong\":\n case \"delete\": {\n const { type, children } = node;\n const nodes = convertNodes(children, {\n ...ctx,\n deco: { ...ctx.deco, [type]: true },\n });\n results.push(...nodes);\n break;\n }\n case \"inlineCode\":\n results.push(buildInlineCode(node));\n break;\n case \"break\":\n results.push(buildBreak(node));\n break;\n case \"link\": {\n results.push(buildLink(node, ctx));\n break;\n }\n case \"linkReference\":\n results.push(...buildLinkReference(node, ctx));\n break;\n case \"image\":\n case \"imageReference\": {\n warnOnce(\n `${node.type} node is not rendered since remark-docx/plugins/image is not provided.`,\n );\n break;\n }\n // case \"footnote\": {\n // // inline footnote was removed in mdast v5\n // break;\n // }\n case \"footnoteReference\":\n results.push(buildFootnoteReference(node, ctx));\n break;\n case \"math\":\n case \"inlineMath\":\n warnOnce(\n `${node.type} node is not rendered since remark-docx/plugins/math is not provided.`,\n );\n break;\n default:\n warnOnce(`${node.type} node is not officially supported.`);\n break;\n }\n }\n return results;\n};\n\nconst buildParagraph = (\n { children }: mdast.Paragraph,\n ctx: Context,\n): DocxContent => {\n const list = ctx.list;\n const nodes = convertNodes(children, ctx);\n\n if (list && list.checked != null) {\n nodes.unshift(\n new CheckBox({\n checked: list.checked,\n checkedState: { value: \"2611\" },\n uncheckedState: { value: \"2610\" },\n }),\n );\n }\n return new Paragraph({\n children: nodes,\n indent:\n ctx.indent > 0\n ? {\n start: convertInchesToTwip(INDENT * ctx.indent),\n }\n : undefined,\n ...(list &&\n (list.ordered\n ? {\n numbering: {\n reference: list.reference,\n level: list.level,\n },\n }\n : {\n bullet: {\n level: list.level,\n },\n })),\n });\n};\n\nconst buildHeading = (\n { children, depth }: mdast.Heading,\n ctx: Context,\n): DocxContent => {\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 = convertNodes(children, ctx);\n return new Paragraph({\n heading: headingLevel,\n children: nodes,\n });\n};\n\nconst buildThematicBreak = (_: mdast.ThematicBreak): DocxContent => {\n return new Paragraph({\n thematicBreak: true,\n });\n};\n\nconst buildBlockquote = (\n { children }: mdast.Blockquote,\n ctx: Context,\n): DocxContent[] => {\n return convertNodes(children, {\n ...ctx,\n indent: ctx.indent + 1,\n });\n};\n\nconst buildList = (\n { children, ordered }: mdast.List,\n ctx: Context,\n): DocxContent[] => {\n const isTopLevel = !ctx.list;\n const list: ListInfo = {\n level: ctx.list ? ctx.list.level + 1 : 0,\n ordered: !!ordered,\n reference:\n isTopLevel && ordered\n ? ctx.numbering.create()\n : ctx.list?.reference || ORDERED_LIST_REF,\n };\n return children.flatMap((item) => {\n return buildListItem(item, {\n ...ctx,\n list,\n });\n });\n};\n\nconst buildListItem = (\n { children, checked }: mdast.ListItem,\n ctx: Context,\n): DocxContent[] => {\n return convertNodes(children, {\n ...ctx,\n ...(ctx.list && { list: { ...ctx.list, checked: checked ?? undefined } }),\n });\n};\n\nconst buildTable = (\n { children, align }: mdast.Table,\n ctx: Context,\n): DocxContent => {\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 = CONTENT_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: convertNodes(c.children, ctx),\n }),\n ],\n });\n }),\n });\n }),\n });\n};\n\nconst buildText = (text: string, deco: Decoration): DocxContent => {\n return new TextRun({\n text,\n bold: deco.strong,\n italics: deco.emphasis,\n strike: deco.delete,\n });\n};\n\nconst buildInlineCode = ({ value }: mdast.InlineCode): DocxContent => {\n return new TextRun({\n text: value,\n highlight: \"lightGray\",\n });\n};\n\nconst buildBreak = (_: mdast.Break): DocxContent => {\n return new TextRun({ text: \"\", break: 1 });\n};\n\nconst buildLink = (\n { children, url }: Pick<mdast.Link, \"children\" | \"url\">,\n ctx: Context,\n): DocxContent => {\n const nodes = convertNodes(children, ctx);\n return new ExternalHyperlink({\n link: url,\n children: nodes,\n });\n};\n\nconst buildLinkReference = (\n { children, identifier }: mdast.LinkReference,\n ctx: Context,\n): DocxContent[] => {\n const def = ctx.definition(identifier);\n if (def == null) {\n return convertNodes(children, ctx);\n }\n return [buildLink({ children, url: def.url }, ctx)];\n};\n\nconst registerFootnoteDefinition = (\n { children, identifier }: mdast.FootnoteDefinition,\n ctx: Context,\n): void => {\n const definition: FootnoteDefinition = {\n children: children.map((node) => {\n // Convert each node and extract the first result as a paragraph\n const nodes = convertNodes([node], ctx);\n if (nodes[0] instanceof Paragraph) {\n return nodes[0] as Paragraph;\n }\n // For non-paragraph content, wrap in a paragraph\n return new Paragraph({ children: nodes });\n }),\n };\n ctx.footnote.def(identifier, definition);\n};\n\nconst buildFootnoteReference = (\n { identifier }: mdast.FootnoteReference,\n ctx: Context,\n): DocxContent => {\n return new FootnoteReferenceRun(ctx.footnote.ref(identifier));\n};\n","import type { Plugin } from \"unified\";\nimport type { Root } from \"mdast\";\nimport { mdastToDocx, type DocxOptions } from \"./mdast-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":["sectionPageSizeDefaults","sectionMarginDefaults","LevelFormat","AlignmentType","convertInchesToTwip","definitions","Document","Packer","CheckBox","Paragraph","HeadingLevel","Table","TableRow","TableCell","TextRun","ExternalHyperlink","FootnoteReferenceRun"],"mappings":";;;;;AAAA;;AAEG;AACG,SAAU,SAAS,CAAC,IAAS,EAAE,OAAe,EAAA;AAClD,IAAW,MAAM,IAAI,KAAK,CAAC,OAAO,CAAC;AACrC;AAEA,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;;ACaA,MAAM,aAAa,GACjBA,4BAAuB,CAAC,KAAK;AAC7B,IAAAC,0BAAqB,CAAC,IAAI;IAC1BA,0BAAqB,CAAC,KAAK;AAC7B,MAAM,gBAAgB,GAAG,SAAS;AAClC,MAAM,MAAM,GAAG,GAAG;AAsBlB,MAAM,sBAAsB,GAAG,MAAuB;AACpD,IAAA,MAAM,cAAc,GAAG,IAAI,GAAG,EAAkB;AAChD,IAAA,MAAM,IAAI,GAAG,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ACrC,QAAQ,EAAE,QAAQ,CAAC,GAAG,CAAC,CAAC,IAAI,KAAI;;YAE9B,MAAM,KAAK,GAAG,YAAY,CAAC,CAAC,IAAI,CAAC,EAAE,GAAG,CAAC;AACvC,YAAA,IAAI,KAAK,CAAC,CAAC,CAAC,YAAYN,cAAS,EAAE;AACjC,gBAAA,OAAO,KAAK,CAAC,CAAC,CAAc;YAC9B;;YAEA,OAAO,IAAIA,cAAS,CAAC,EAAE,QAAQ,EAAE,KAAK,EAAE,CAAC;AAC3C,QAAA,CAAC,CAAC;KACH;IACD,GAAG,CAAC,QAAQ,CAAC,GAAG,CAAC,UAAU,EAAE,UAAU,CAAC;AAC1C,CAAC;AAED,MAAM,sBAAsB,GAAG,CAC7B,EAAE,UAAU,EAA2B,EACvC,GAAY,KACG;AACf,IAAA,OAAO,IAAIO,yBAAoB,CAAC,GAAG,CAAC,QAAQ,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC;AAC/D,CAAC;;ACnlBD,MAAM,MAAM,GAAuD,UACjE,IAAI,GAAG,EAAE,EAAA;AAET,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 CheckBox,\n type IPropertiesOptions,\n sectionPageSizeDefaults,\n sectionMarginDefaults,\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 NodeBuilder,\n NodeBuilders,\n NumberingRegistry,\n RemarkDocxPlugin,\n} from \"./types\";\n\nconst CONTENT_WIDTH =\n sectionPageSizeDefaults.WIDTH -\n sectionMarginDefaults.LEFT -\n sectionMarginDefaults.RIGHT;\nconst ORDERED_LIST_REF = \"ordered\";\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\nconst createNumberingRegistry = (): NumberingRegistry => {\n let counter = 1;\n\n const DEFAULT_NUMBERINGS: ILevelsOptions[] = [\n {\n level: 0,\n format: LevelFormat.DECIMAL,\n text: \"%1.\",\n alignment: AlignmentType.START,\n },\n {\n level: 1,\n format: LevelFormat.DECIMAL,\n text: \"%2.\",\n alignment: AlignmentType.START,\n style: {\n paragraph: {\n indent: { start: convertInchesToTwip(INDENT * 1) },\n },\n },\n },\n {\n level: 2,\n format: LevelFormat.DECIMAL,\n text: \"%3.\",\n alignment: AlignmentType.START,\n style: {\n paragraph: {\n indent: { start: convertInchesToTwip(INDENT * 2) },\n },\n },\n },\n {\n level: 3,\n format: LevelFormat.DECIMAL,\n text: \"%4.\",\n alignment: AlignmentType.START,\n style: {\n paragraph: {\n indent: { start: convertInchesToTwip(INDENT * 3) },\n },\n },\n },\n {\n level: 4,\n format: LevelFormat.DECIMAL,\n text: \"%5.\",\n alignment: AlignmentType.START,\n style: {\n paragraph: {\n indent: { start: convertInchesToTwip(INDENT * 4) },\n },\n },\n },\n {\n level: 5,\n format: LevelFormat.DECIMAL,\n text: \"%6.\",\n alignment: AlignmentType.START,\n style: {\n paragraph: {\n indent: { start: convertInchesToTwip(INDENT * 5) },\n },\n },\n },\n ];\n\n return {\n create: () => {\n return `${ORDERED_LIST_REF}-${counter++}`;\n },\n toConfig: () => {\n return Array.from({ length: counter }, (_, i) => ({\n reference: `${ORDERED_LIST_REF}-${i}`,\n levels: DEFAULT_NUMBERINGS,\n }));\n },\n };\n};\n\nexport interface DocxOptions extends Pick<\n IPropertiesOptions,\n | \"title\"\n | \"subject\"\n | \"creator\"\n | \"keywords\"\n | \"description\"\n | \"lastModifiedBy\"\n | \"revision\"\n | \"styles\"\n | \"background\"\n> {\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 lastModifiedBy,\n revision,\n styles,\n background,\n }: DocxOptions = {},\n): Promise<ArrayBuffer> => {\n const definition = definitions(node);\n\n const footnote = createFootnoteRegistry();\n const numbering = createNumberingRegistry();\n\n const pluginCtx = { root: node, definition };\n\n const builders = (\n await Promise.all(plugins.map((p) => p(pluginCtx)))\n ).reduceRight<NodeBuilders>(\n (acc, p) => {\n type Key = keyof typeof p;\n for (const k of Object.keys(p)) {\n acc[k as Key] = p[k as Key] as any;\n }\n return acc;\n },\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 deco: {},\n indent: 0,\n definition: definition,\n footnote,\n numbering,\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 doc = new Document({\n title,\n subject,\n creator,\n keywords,\n description,\n lastModifiedBy,\n revision,\n styles,\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: numbering.toConfig(),\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 if (list && list.checked != null) {\n nodes.unshift(\n new CheckBox({\n checked: list.checked,\n checkedState: { value: \"2611\" },\n uncheckedState: { value: \"2610\" },\n }),\n );\n }\n return new Paragraph({\n children: nodes,\n indent:\n ctx.indent > 0\n ? {\n start: convertInchesToTwip(INDENT * ctx.indent),\n }\n : undefined,\n ...(list &&\n (list.ordered\n ? {\n numbering: {\n reference: list.reference,\n level: list.level,\n },\n }\n : {\n bullet: {\n level: list.level,\n },\n })),\n });\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\"> = () => {\n // Returning empty array at toplevel means section insertion.\n return [];\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 isTopLevel = !ctx.list;\n const reference =\n isTopLevel && ordered\n ? ctx.numbering.create()\n : ctx.list?.reference || ORDERED_LIST_REF;\n\n return ctx.render(children, {\n ...ctx,\n list: {\n level: isTopLevel ? 0 : ctx.list.level + 1,\n ordered: !!ordered,\n reference,\n },\n });\n};\n\nconst buildListItem: NodeBuilder<\"listItem\"> = ({ children, checked }, ctx) => {\n return ctx.render(children, {\n ...ctx,\n ...(ctx.list && { list: { ...ctx.list, checked: checked ?? undefined } }),\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 = CONTENT_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 return new TextRun({\n text: value,\n bold: deco.bold,\n italics: deco.italic,\n strike: deco.strike,\n });\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 highlight: \"lightGray\",\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 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":["sectionPageSizeDefaults","sectionMarginDefaults","LevelFormat","AlignmentType","convertInchesToTwip","definitions","Document","Packer","CheckBox","Paragraph","HeadingLevel","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;;ACwBA,MAAM,aAAa,GACjBA,4BAAuB,CAAC,KAAK;AAC7B,IAAAC,0BAAqB,CAAC,IAAI;IAC1BA,0BAAqB,CAAC,KAAK;AAC7B,MAAM,gBAAgB,GAAG,SAAS;AAClC,MAAM,MAAM,GAAG,GAAG;AAElB,MAAM,s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