remark-docx 0.3.9 → 0.3.10
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 +106 -162
- package/lib/index.cjs.map +1 -1
- package/lib/index.js +106 -162
- package/lib/index.js.map +1 -1
- package/lib/mdast-to-docx.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 +42 -5
- package/package.json +1 -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
|
},
|
|
@@ -133,14 +127,63 @@ const mdastToDocx = async (node, { plugins = [], title, subject, creator, keywor
|
|
|
133
127
|
const footnote = createFootnoteRegistry();
|
|
134
128
|
const numbering = createNumberingRegistry();
|
|
135
129
|
const pluginCtx = { root: node, definition };
|
|
136
|
-
const
|
|
137
|
-
|
|
130
|
+
const defaultBuilders = {
|
|
131
|
+
paragraph: buildParagraph,
|
|
132
|
+
heading: buildHeading,
|
|
133
|
+
thematicBreak: buildThematicBreak,
|
|
134
|
+
blockquote: buildBlockquote,
|
|
135
|
+
list: buildList,
|
|
136
|
+
listItem: buildListItem,
|
|
137
|
+
table: buildTable,
|
|
138
|
+
tableRow: noop,
|
|
139
|
+
tableCell: noop,
|
|
140
|
+
html: fallbackText,
|
|
141
|
+
code: fallbackText,
|
|
142
|
+
definition: noop,
|
|
143
|
+
footnoteDefinition: buildFootnoteDefinition,
|
|
144
|
+
text: buildText,
|
|
145
|
+
emphasis: buildEmphasis,
|
|
146
|
+
strong: buildStrong,
|
|
147
|
+
delete: buildDelete,
|
|
148
|
+
inlineCode: buildInlineCode,
|
|
149
|
+
break: buildBreak,
|
|
150
|
+
link: buildLink,
|
|
151
|
+
linkReference: buildLinkReference,
|
|
152
|
+
// image: warnImage,
|
|
153
|
+
// imageReference: warnImage,
|
|
154
|
+
footnoteReference: buildFootnoteReference,
|
|
155
|
+
math: fallbackText,
|
|
156
|
+
inlineMath: fallbackText,
|
|
157
|
+
};
|
|
158
|
+
const builders = (await Promise.all(plugins.map((p) => p(pluginCtx)))).reduceRight((acc, p) => ({ ...acc, ...p }), defaultBuilders);
|
|
159
|
+
const ctx = {
|
|
160
|
+
next(nodes, c) {
|
|
161
|
+
const results = [];
|
|
162
|
+
for (const node of nodes) {
|
|
163
|
+
const builder = builders[node.type];
|
|
164
|
+
if (!builder) {
|
|
165
|
+
warnOnce(`${node.type} node is not supported without plugins.`);
|
|
166
|
+
continue;
|
|
167
|
+
}
|
|
168
|
+
const r = builder(node, c !== null && c !== void 0 ? c : this);
|
|
169
|
+
if (r) {
|
|
170
|
+
if (Array.isArray(r)) {
|
|
171
|
+
results.push(...r);
|
|
172
|
+
}
|
|
173
|
+
else {
|
|
174
|
+
results.push(r);
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
return results;
|
|
179
|
+
},
|
|
138
180
|
deco: {},
|
|
139
181
|
indent: 0,
|
|
140
182
|
definition: definition,
|
|
141
183
|
footnote,
|
|
142
184
|
numbering,
|
|
143
|
-
}
|
|
185
|
+
};
|
|
186
|
+
const nodes = ctx.next(node.children);
|
|
144
187
|
const doc = new docx.Document({
|
|
145
188
|
title,
|
|
146
189
|
subject,
|
|
@@ -159,121 +202,9 @@ const mdastToDocx = async (node, { plugins = [], title, subject, creator, keywor
|
|
|
159
202
|
});
|
|
160
203
|
return docx.Packer.toArrayBuffer(doc);
|
|
161
204
|
};
|
|
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
205
|
const buildParagraph = ({ children }, ctx) => {
|
|
275
206
|
const list = ctx.list;
|
|
276
|
-
const nodes =
|
|
207
|
+
const nodes = ctx.next(children);
|
|
277
208
|
if (list && list.checked != null) {
|
|
278
209
|
nodes.unshift(new docx.CheckBox({
|
|
279
210
|
checked: list.checked,
|
|
@@ -325,19 +256,19 @@ const buildHeading = ({ children, depth }, ctx) => {
|
|
|
325
256
|
headingLevel = docx.HeadingLevel.HEADING_5;
|
|
326
257
|
break;
|
|
327
258
|
}
|
|
328
|
-
const nodes =
|
|
259
|
+
const nodes = ctx.next(children);
|
|
329
260
|
return new docx.Paragraph({
|
|
330
261
|
heading: headingLevel,
|
|
331
262
|
children: nodes,
|
|
332
263
|
});
|
|
333
264
|
};
|
|
334
|
-
const buildThematicBreak = (
|
|
265
|
+
const buildThematicBreak = () => {
|
|
335
266
|
return new docx.Paragraph({
|
|
336
267
|
thematicBreak: true,
|
|
337
268
|
});
|
|
338
269
|
};
|
|
339
270
|
const buildBlockquote = ({ children }, ctx) => {
|
|
340
|
-
return
|
|
271
|
+
return ctx.next(children, {
|
|
341
272
|
...ctx,
|
|
342
273
|
indent: ctx.indent + 1,
|
|
343
274
|
});
|
|
@@ -345,22 +276,20 @@ const buildBlockquote = ({ children }, ctx) => {
|
|
|
345
276
|
const buildList = ({ children, ordered }, ctx) => {
|
|
346
277
|
var _a;
|
|
347
278
|
const isTopLevel = !ctx.list;
|
|
348
|
-
const
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
list,
|
|
359
|
-
});
|
|
279
|
+
const reference = isTopLevel && ordered
|
|
280
|
+
? ctx.numbering.create()
|
|
281
|
+
: ((_a = ctx.list) === null || _a === void 0 ? void 0 : _a.reference) || ORDERED_LIST_REF;
|
|
282
|
+
return ctx.next(children, {
|
|
283
|
+
...ctx,
|
|
284
|
+
list: {
|
|
285
|
+
level: isTopLevel ? 0 : ctx.list.level + 1,
|
|
286
|
+
ordered: !!ordered,
|
|
287
|
+
reference,
|
|
288
|
+
},
|
|
360
289
|
});
|
|
361
290
|
};
|
|
362
291
|
const buildListItem = ({ children, checked }, ctx) => {
|
|
363
|
-
return
|
|
292
|
+
return ctx.next(children, {
|
|
364
293
|
...ctx,
|
|
365
294
|
...(ctx.list && { list: { ...ctx.list, checked: checked !== null && checked !== void 0 ? checked : undefined } }),
|
|
366
295
|
});
|
|
@@ -390,7 +319,7 @@ const buildTable = ({ children, align }, ctx) => {
|
|
|
390
319
|
children: [
|
|
391
320
|
new docx.Paragraph({
|
|
392
321
|
alignment: cellAligns === null || cellAligns === void 0 ? void 0 : cellAligns[i],
|
|
393
|
-
children:
|
|
322
|
+
children: ctx.next(c.children),
|
|
394
323
|
}),
|
|
395
324
|
],
|
|
396
325
|
});
|
|
@@ -399,12 +328,30 @@ const buildTable = ({ children, align }, ctx) => {
|
|
|
399
328
|
}),
|
|
400
329
|
});
|
|
401
330
|
};
|
|
402
|
-
const buildText = (
|
|
331
|
+
const buildText = ({ value }, { deco }) => {
|
|
403
332
|
return new docx.TextRun({
|
|
404
|
-
text,
|
|
405
|
-
bold: deco.
|
|
406
|
-
italics: deco.
|
|
407
|
-
strike: deco.
|
|
333
|
+
text: value,
|
|
334
|
+
bold: deco.bold,
|
|
335
|
+
italics: deco.italic,
|
|
336
|
+
strike: deco.strike,
|
|
337
|
+
});
|
|
338
|
+
};
|
|
339
|
+
const buildEmphasis = ({ children }, ctx) => {
|
|
340
|
+
return ctx.next(children, {
|
|
341
|
+
...ctx,
|
|
342
|
+
deco: { ...ctx.deco, italic: true },
|
|
343
|
+
});
|
|
344
|
+
};
|
|
345
|
+
const buildStrong = ({ children }, ctx) => {
|
|
346
|
+
return ctx.next(children, {
|
|
347
|
+
...ctx,
|
|
348
|
+
deco: { ...ctx.deco, bold: true },
|
|
349
|
+
});
|
|
350
|
+
};
|
|
351
|
+
const buildDelete = ({ children }, ctx) => {
|
|
352
|
+
return ctx.next(children, {
|
|
353
|
+
...ctx,
|
|
354
|
+
deco: { ...ctx.deco, strike: true },
|
|
408
355
|
});
|
|
409
356
|
};
|
|
410
357
|
const buildInlineCode = ({ value }) => {
|
|
@@ -413,11 +360,11 @@ const buildInlineCode = ({ value }) => {
|
|
|
413
360
|
highlight: "lightGray",
|
|
414
361
|
});
|
|
415
362
|
};
|
|
416
|
-
const buildBreak = (
|
|
363
|
+
const buildBreak = () => {
|
|
417
364
|
return new docx.TextRun({ text: "", break: 1 });
|
|
418
365
|
};
|
|
419
366
|
const buildLink = ({ children, url }, ctx) => {
|
|
420
|
-
const nodes =
|
|
367
|
+
const nodes = ctx.next(children);
|
|
421
368
|
return new docx.ExternalHyperlink({
|
|
422
369
|
link: url,
|
|
423
370
|
children: nodes,
|
|
@@ -426,27 +373,24 @@ const buildLink = ({ children, url }, ctx) => {
|
|
|
426
373
|
const buildLinkReference = ({ children, identifier }, ctx) => {
|
|
427
374
|
const def = ctx.definition(identifier);
|
|
428
375
|
if (def == null) {
|
|
429
|
-
return
|
|
376
|
+
return ctx.next(children);
|
|
430
377
|
}
|
|
431
|
-
return
|
|
378
|
+
return buildLink({ children, url: def.url }, ctx);
|
|
432
379
|
};
|
|
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);
|
|
380
|
+
const buildFootnoteDefinition = ({ children, identifier }, ctx) => {
|
|
381
|
+
ctx.footnote.def(identifier, ctx.next(children).filter((c) => c instanceof docx.Paragraph));
|
|
382
|
+
return null;
|
|
446
383
|
};
|
|
447
384
|
const buildFootnoteReference = ({ identifier }, ctx) => {
|
|
448
385
|
return new docx.FootnoteReferenceRun(ctx.footnote.ref(identifier));
|
|
449
386
|
};
|
|
387
|
+
const noop = () => {
|
|
388
|
+
return null;
|
|
389
|
+
};
|
|
390
|
+
const fallbackText = (node, ctx) => {
|
|
391
|
+
warnOnce(`${node.type} node is not supported without plugins, falling back to text.`);
|
|
392
|
+
return buildText({ value: node.value }, ctx);
|
|
393
|
+
};
|
|
450
394
|
|
|
451
395
|
const plugin = function (opts = {}) {
|
|
452
396
|
this.compiler = (node) => {
|
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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CAAC,GAAG,EAAE,EAAE,GAAG,CAAC,CAAC;AACrD,CAAC;AAED,MAAM,0BAA0B,GAAG,CACjC,EAAE,QAAQ,EAAE,UAAU,EAA4B,EAClD,GAAY,KACJ;AACR,IAAA,MAAM,UAAU,GAAuB;QACrC,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-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 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\n const defaultBuilders: NodeBuilders = {\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 const builders = (\n await Promise.all(plugins.map((p) => p(pluginCtx)))\n ).reduceRight((acc, p) => ({ ...acc, ...p }), defaultBuilders);\n\n const ctx: Context = {\n next(nodes, c) {\n const results: DocxContent[] = [];\n for (const node of nodes) {\n const builder = builders[node.type];\n if (!builder) {\n warnOnce(`${node.type} node is not supported without plugins.`);\n continue;\n }\n const r = builder(node as any, c ?? this);\n if (r) {\n if (Array.isArray(r)) {\n results.push(...r);\n } else {\n results.push(r);\n }\n }\n }\n return results;\n },\n deco: {},\n indent: 0,\n definition: definition,\n footnote,\n numbering,\n };\n\n const nodes = ctx.next(node.children);\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 buildParagraph: NodeBuilder<\"paragraph\"> = ({ children }, ctx) => {\n const list = ctx.list;\n const nodes = ctx.next(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.next(children);\n return new Paragraph({\n heading: headingLevel,\n children: nodes,\n });\n};\n\nconst buildThematicBreak: NodeBuilder<\"thematicBreak\"> = () => {\n return new Paragraph({\n thematicBreak: true,\n });\n};\n\nconst buildBlockquote: NodeBuilder<\"blockquote\"> = ({ children }, ctx) => {\n return ctx.next(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.next(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.next(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.next(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.next(children, {\n ...ctx,\n deco: { ...ctx.deco, italic: true },\n });\n};\n\nconst buildStrong: NodeBuilder<\"strong\"> = ({ children }, ctx) => {\n return ctx.next(children, {\n ...ctx,\n deco: { ...ctx.deco, bold: true },\n });\n};\n\nconst buildDelete: NodeBuilder<\"delete\"> = ({ children }, ctx) => {\n return ctx.next(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.next(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.next(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.next(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-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,sBAAsB,GAAG,MAAuB;AACpD,IAAA,MAAM,cAAc,GAAG,IAAI,GAAG,EAAkB;AAChD,IAAA,MAAM,IAAI,GAAG,IAAI,GAAG,EAAuB;AAE3C,IAAA,MAAM,KAAK,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