remark-docx 0.3.14 → 0.3.15
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 +119 -95
- package/lib/index.cjs.map +1 -1
- package/lib/index.js +120 -96
- package/lib/index.js.map +1 -1
- package/lib/mdast-util-to-docx.d.ts +13 -2
- package/lib/plugins/image/index.cjs +4 -14
- package/lib/plugins/image/index.cjs.map +1 -1
- package/lib/plugins/image/index.js +1 -11
- package/lib/plugins/image/index.js.map +1 -1
- package/lib/plugins/latex/index.cjs +1 -1
- package/lib/plugins/latex/index.cjs.map +1 -1
- package/lib/plugins/latex/index.d.ts +1 -1
- package/lib/plugins/latex/index.js +1 -1
- package/lib/plugins/latex/index.js.map +1 -1
- package/lib/plugins/shiki/index.cjs +13 -5
- package/lib/plugins/shiki/index.cjs.map +1 -1
- package/lib/plugins/shiki/index.js +13 -5
- package/lib/plugins/shiki/index.js.map +1 -1
- package/lib/types.d.ts +16 -8
- package/lib/utils-19qN-XsS.js +15 -0
- package/lib/utils-19qN-XsS.js.map +1 -0
- package/lib/utils-BWBt3EKb.js +13 -0
- package/lib/utils-BWBt3EKb.js.map +1 -0
- package/package.json +1 -1
package/lib/index.cjs
CHANGED
|
@@ -18,6 +18,9 @@ const CONTENT_WIDTH = docx.sectionPageSizeDefaults.WIDTH -
|
|
|
18
18
|
docx.sectionMarginDefaults.LEFT -
|
|
19
19
|
docx.sectionMarginDefaults.RIGHT;
|
|
20
20
|
const ORDERED_LIST_REF = "ordered";
|
|
21
|
+
const TASK_LIST_REF = "task";
|
|
22
|
+
const HYPERLINK_STYLE_ID = "Hyperlink";
|
|
23
|
+
const INLINE_CODE_STYLE_ID = "InlineCode";
|
|
21
24
|
const INDENT = 0.5;
|
|
22
25
|
const createFootnoteRegistry = () => {
|
|
23
26
|
const idToInternalId = new Map();
|
|
@@ -47,92 +50,70 @@ const createFootnoteRegistry = () => {
|
|
|
47
50
|
};
|
|
48
51
|
const createNumberingRegistry = () => {
|
|
49
52
|
let counter = 1;
|
|
50
|
-
const DEFAULT_NUMBERINGS = [
|
|
51
|
-
{
|
|
52
|
-
level: 0,
|
|
53
|
-
format: docx.LevelFormat.DECIMAL,
|
|
54
|
-
text: "%1.",
|
|
55
|
-
alignment: docx.AlignmentType.START,
|
|
56
|
-
},
|
|
57
|
-
{
|
|
58
|
-
level: 1,
|
|
59
|
-
format: docx.LevelFormat.DECIMAL,
|
|
60
|
-
text: "%2.",
|
|
61
|
-
alignment: docx.AlignmentType.START,
|
|
62
|
-
style: {
|
|
63
|
-
paragraph: {
|
|
64
|
-
indent: { start: docx.convertInchesToTwip(INDENT * 1) },
|
|
65
|
-
},
|
|
66
|
-
},
|
|
67
|
-
},
|
|
68
|
-
{
|
|
69
|
-
level: 2,
|
|
70
|
-
format: docx.LevelFormat.DECIMAL,
|
|
71
|
-
text: "%3.",
|
|
72
|
-
alignment: docx.AlignmentType.START,
|
|
73
|
-
style: {
|
|
74
|
-
paragraph: {
|
|
75
|
-
indent: { start: docx.convertInchesToTwip(INDENT * 2) },
|
|
76
|
-
},
|
|
77
|
-
},
|
|
78
|
-
},
|
|
79
|
-
{
|
|
80
|
-
level: 3,
|
|
81
|
-
format: docx.LevelFormat.DECIMAL,
|
|
82
|
-
text: "%4.",
|
|
83
|
-
alignment: docx.AlignmentType.START,
|
|
84
|
-
style: {
|
|
85
|
-
paragraph: {
|
|
86
|
-
indent: { start: docx.convertInchesToTwip(INDENT * 3) },
|
|
87
|
-
},
|
|
88
|
-
},
|
|
89
|
-
},
|
|
90
|
-
{
|
|
91
|
-
level: 4,
|
|
92
|
-
format: docx.LevelFormat.DECIMAL,
|
|
93
|
-
text: "%5.",
|
|
94
|
-
alignment: docx.AlignmentType.START,
|
|
95
|
-
style: {
|
|
96
|
-
paragraph: {
|
|
97
|
-
indent: { start: docx.convertInchesToTwip(INDENT * 4) },
|
|
98
|
-
},
|
|
99
|
-
},
|
|
100
|
-
},
|
|
101
|
-
{
|
|
102
|
-
level: 5,
|
|
103
|
-
format: docx.LevelFormat.DECIMAL,
|
|
104
|
-
text: "%6.",
|
|
105
|
-
alignment: docx.AlignmentType.START,
|
|
106
|
-
style: {
|
|
107
|
-
paragraph: {
|
|
108
|
-
indent: { start: docx.convertInchesToTwip(INDENT * 5) },
|
|
109
|
-
},
|
|
110
|
-
},
|
|
111
|
-
},
|
|
112
|
-
];
|
|
113
53
|
return {
|
|
114
|
-
|
|
54
|
+
createId: () => {
|
|
115
55
|
return `${ORDERED_LIST_REF}-${counter++}`;
|
|
116
56
|
},
|
|
117
|
-
|
|
118
|
-
return Array.from({ length: counter }, (_, i) =>
|
|
119
|
-
reference: `${ORDERED_LIST_REF}-${i}`,
|
|
120
|
-
levels: DEFAULT_NUMBERINGS,
|
|
121
|
-
}));
|
|
57
|
+
getIds: () => {
|
|
58
|
+
return Array.from({ length: counter }, (_, i) => `${ORDERED_LIST_REF}-${i}`);
|
|
122
59
|
},
|
|
123
60
|
};
|
|
124
61
|
};
|
|
125
|
-
const
|
|
62
|
+
const composeBuilders = (pluginsBuilders, defaultBuilders) => {
|
|
63
|
+
return pluginsBuilders.reduceRight((acc, p) => {
|
|
64
|
+
for (const [k, cur] of Object.entries(p)) {
|
|
65
|
+
const prev = acc[k];
|
|
66
|
+
acc[k] = (prev
|
|
67
|
+
? (n, c) => {
|
|
68
|
+
const r = cur(n, c);
|
|
69
|
+
if (r) {
|
|
70
|
+
return r;
|
|
71
|
+
}
|
|
72
|
+
return prev(n, c);
|
|
73
|
+
}
|
|
74
|
+
: cur);
|
|
75
|
+
}
|
|
76
|
+
return acc;
|
|
77
|
+
}, defaultBuilders);
|
|
78
|
+
};
|
|
79
|
+
const defaultTaskList = [
|
|
80
|
+
{ text: "", format: "NONE" },
|
|
81
|
+
{ text: "", format: "NONE" },
|
|
82
|
+
{ text: "", format: "NONE" },
|
|
83
|
+
{ text: "", format: "NONE" },
|
|
84
|
+
{ text: "", format: "NONE" },
|
|
85
|
+
{ text: "", format: "NONE" },
|
|
86
|
+
];
|
|
87
|
+
const defaultOrderedList = [
|
|
88
|
+
{ text: "%1.", format: "DECIMAL" },
|
|
89
|
+
{ text: "%2.", format: "DECIMAL" },
|
|
90
|
+
{ text: "%3.", format: "DECIMAL" },
|
|
91
|
+
{ text: "%4.", format: "DECIMAL" },
|
|
92
|
+
{ text: "%5.", format: "DECIMAL" },
|
|
93
|
+
{ text: "%6.", format: "DECIMAL" },
|
|
94
|
+
];
|
|
95
|
+
const buildLevels = (formats) => formats.map(({ format, text }, i) => {
|
|
96
|
+
return {
|
|
97
|
+
level: i,
|
|
98
|
+
format: docx.LevelFormat[format],
|
|
99
|
+
text: text,
|
|
100
|
+
alignment: docx.AlignmentType.START,
|
|
101
|
+
style: i === 0
|
|
102
|
+
? undefined
|
|
103
|
+
: {
|
|
104
|
+
paragraph: {
|
|
105
|
+
indent: { start: docx.convertInchesToTwip(INDENT * i) },
|
|
106
|
+
},
|
|
107
|
+
},
|
|
108
|
+
};
|
|
109
|
+
});
|
|
110
|
+
const mdastToDocx = async (node, { plugins = [], title, subject, creator, keywords, description, styles, background, orderedListFormat = defaultOrderedList, } = {}) => {
|
|
111
|
+
var _a;
|
|
126
112
|
const definition = mdastUtilDefinitions.definitions(node);
|
|
127
|
-
const footnote = createFootnoteRegistry();
|
|
128
113
|
const numbering = createNumberingRegistry();
|
|
114
|
+
const footnote = createFootnoteRegistry();
|
|
129
115
|
const pluginCtx = { root: node, definition };
|
|
130
|
-
const builders = (await Promise.all(plugins.map((p) => p(pluginCtx)))
|
|
131
|
-
for (const k of Object.keys(p)) {
|
|
132
|
-
acc[k] = p[k];
|
|
133
|
-
}
|
|
134
|
-
return acc;
|
|
135
|
-
}, {
|
|
116
|
+
const builders = composeBuilders(await Promise.all(plugins.map((p) => p(pluginCtx))), {
|
|
136
117
|
paragraph: buildParagraph,
|
|
137
118
|
heading: buildHeading,
|
|
138
119
|
thematicBreak: buildThematicBreak,
|
|
@@ -192,7 +173,7 @@ const mdastToDocx = async (node, { plugins = [], title, subject, creator, keywor
|
|
|
192
173
|
indent: 0,
|
|
193
174
|
definition: definition,
|
|
194
175
|
footnote,
|
|
195
|
-
numbering,
|
|
176
|
+
orderedListId: numbering.createId,
|
|
196
177
|
};
|
|
197
178
|
const sections = [[]];
|
|
198
179
|
for (const n of node.children) {
|
|
@@ -208,20 +189,41 @@ const mdastToDocx = async (node, { plugins = [], title, subject, creator, keywor
|
|
|
208
189
|
}
|
|
209
190
|
}
|
|
210
191
|
}
|
|
192
|
+
const orderedLevels = buildLevels(orderedListFormat);
|
|
211
193
|
const doc = new docx.Document({
|
|
212
194
|
title,
|
|
213
195
|
subject,
|
|
214
196
|
creator,
|
|
215
197
|
keywords,
|
|
216
198
|
description,
|
|
217
|
-
styles
|
|
199
|
+
styles: {
|
|
200
|
+
...styles,
|
|
201
|
+
characterStyles: [
|
|
202
|
+
...((_a = styles === null || styles === void 0 ? void 0 : styles.characterStyles) !== null && _a !== void 0 ? _a : []),
|
|
203
|
+
{
|
|
204
|
+
id: INLINE_CODE_STYLE_ID,
|
|
205
|
+
run: {
|
|
206
|
+
highlight: "lightGray",
|
|
207
|
+
},
|
|
208
|
+
},
|
|
209
|
+
],
|
|
210
|
+
},
|
|
218
211
|
background,
|
|
219
212
|
sections: sections
|
|
220
213
|
.filter((s) => s.length)
|
|
221
214
|
.map((s) => ({ children: s })),
|
|
222
215
|
footnotes: footnote.toConfig(),
|
|
223
216
|
numbering: {
|
|
224
|
-
config:
|
|
217
|
+
config: [
|
|
218
|
+
...numbering.getIds().map((ref) => ({
|
|
219
|
+
reference: ref,
|
|
220
|
+
levels: orderedLevels,
|
|
221
|
+
})),
|
|
222
|
+
{
|
|
223
|
+
reference: TASK_LIST_REF,
|
|
224
|
+
levels: buildLevels(defaultTaskList),
|
|
225
|
+
},
|
|
226
|
+
],
|
|
225
227
|
},
|
|
226
228
|
});
|
|
227
229
|
return docx.Packer.toArrayBuffer(doc);
|
|
@@ -238,14 +240,18 @@ const buildParagraph = ({ children }, ctx) => {
|
|
|
238
240
|
};
|
|
239
241
|
}
|
|
240
242
|
if (list) {
|
|
241
|
-
if (list.
|
|
243
|
+
if (list.type === "task") {
|
|
242
244
|
nodes.unshift(new docx.CheckBox({
|
|
243
245
|
checked: list.checked,
|
|
244
246
|
checkedState: { value: "2611" },
|
|
245
247
|
uncheckedState: { value: "2610" },
|
|
246
248
|
}));
|
|
249
|
+
options.numbering = {
|
|
250
|
+
reference: TASK_LIST_REF,
|
|
251
|
+
level: list.level,
|
|
252
|
+
};
|
|
247
253
|
}
|
|
248
|
-
if (list.ordered) {
|
|
254
|
+
else if (list.type === "ordered") {
|
|
249
255
|
options.numbering = {
|
|
250
256
|
reference: list.reference,
|
|
251
257
|
level: list.level,
|
|
@@ -298,24 +304,42 @@ const buildBlockquote = ({ children }, ctx) => {
|
|
|
298
304
|
});
|
|
299
305
|
};
|
|
300
306
|
const buildList = ({ children, ordered }, ctx) => {
|
|
301
|
-
var _a;
|
|
302
307
|
const isTopLevel = !ctx.list;
|
|
303
|
-
const
|
|
304
|
-
|
|
305
|
-
|
|
308
|
+
const level = isTopLevel ? 0 : ctx.list.level + 1;
|
|
309
|
+
const parentList = ctx.list;
|
|
310
|
+
let list;
|
|
311
|
+
if (ordered) {
|
|
312
|
+
list = {
|
|
313
|
+
type: "ordered",
|
|
314
|
+
level,
|
|
315
|
+
reference: parentList && parentList.type === "ordered"
|
|
316
|
+
? parentList.reference
|
|
317
|
+
: ctx.orderedListId(),
|
|
318
|
+
};
|
|
319
|
+
}
|
|
320
|
+
else {
|
|
321
|
+
list = { type: "bullet", level };
|
|
322
|
+
}
|
|
306
323
|
return ctx.render(children, {
|
|
307
324
|
...ctx,
|
|
308
|
-
list
|
|
309
|
-
level: isTopLevel ? 0 : ctx.list.level + 1,
|
|
310
|
-
ordered: !!ordered,
|
|
311
|
-
reference,
|
|
312
|
-
},
|
|
325
|
+
list,
|
|
313
326
|
});
|
|
314
327
|
};
|
|
315
328
|
const buildListItem = ({ children, checked }, ctx) => {
|
|
329
|
+
let list = ctx.list;
|
|
330
|
+
if (list) {
|
|
331
|
+
// listItem must be the child of list
|
|
332
|
+
if (checked != null) {
|
|
333
|
+
list = {
|
|
334
|
+
type: "task",
|
|
335
|
+
level: list.level,
|
|
336
|
+
checked,
|
|
337
|
+
};
|
|
338
|
+
}
|
|
339
|
+
}
|
|
316
340
|
return ctx.render(children, {
|
|
317
341
|
...ctx,
|
|
318
|
-
|
|
342
|
+
list,
|
|
319
343
|
});
|
|
320
344
|
};
|
|
321
345
|
const buildTable = ({ children, align }, ctx) => {
|
|
@@ -360,8 +384,8 @@ const buildText = ({ value }, { deco }) => {
|
|
|
360
384
|
strike: deco.strike,
|
|
361
385
|
};
|
|
362
386
|
if (deco.link) {
|
|
363
|
-
|
|
364
|
-
options.
|
|
387
|
+
// https://docx.js.org/#/usage/hyperlinks?id=styling-hyperlinks
|
|
388
|
+
options.style = HYPERLINK_STYLE_ID;
|
|
365
389
|
}
|
|
366
390
|
return new docx.TextRun(options);
|
|
367
391
|
};
|
|
@@ -386,7 +410,7 @@ const buildDelete = ({ children }, ctx) => {
|
|
|
386
410
|
const buildInlineCode = ({ value }) => {
|
|
387
411
|
return new docx.TextRun({
|
|
388
412
|
text: value,
|
|
389
|
-
|
|
413
|
+
style: INLINE_CODE_STYLE_ID,
|
|
390
414
|
});
|
|
391
415
|
};
|
|
392
416
|
const buildBreak = () => {
|
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} 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 Writeable,\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 | \"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 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 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 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 if (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\n if (list.ordered) {\n options.numbering = {\n reference: list.reference,\n level: list.level,\n };\n } else {\n options.bullet = {\n level: list.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\"> = () => {\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 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 options.color = \"#0563c1\";\n options.underline = { type: \"single\" };\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 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 ...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":["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;AA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../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} 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 ListInfo,\n NodeBuilder,\n NodeBuilders,\n RemarkDocxPlugin,\n Writeable,\n} from \"./types\";\n\nconst CONTENT_WIDTH =\n sectionPageSizeDefaults.WIDTH -\n sectionMarginDefaults.LEFT -\n sectionMarginDefaults.RIGHT;\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 * 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 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 deco: {},\n indent: 0,\n definition: definition,\n footnote,\n orderedListId: 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 if (list.type === \"task\") {\n nodes.unshift(\n new CheckBox({\n checked: list.checked,\n checkedState: { value: \"2611\" },\n uncheckedState: { value: \"2610\" },\n }),\n );\n options.numbering = {\n reference: TASK_LIST_REF,\n level: list.level,\n };\n } else if (list.type === \"ordered\") {\n options.numbering = {\n reference: list.reference,\n level: list.level,\n };\n } else {\n options.bullet = {\n level: list.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\"> = () => {\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 level = isTopLevel ? 0 : ctx.list.level + 1;\n\n const parentList = ctx.list;\n let list: ListInfo;\n if (ordered) {\n list = {\n type: \"ordered\",\n level,\n reference:\n parentList && parentList.type === \"ordered\"\n ? parentList.reference\n : ctx.orderedListId(),\n };\n } else {\n list = { type: \"bullet\", level };\n }\n\n return ctx.render(children, {\n ...ctx,\n list,\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 type: \"task\",\n level: list.level,\n checked,\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 = 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 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":["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;;AC2BA,MAAM,aAAa,GACjBA,4BAAuB,CAAC,KAAK;AAC7B,IAAAC,0BAAqB,CAAC,IAAI;IAC1BA,0BAAqB,CAAC,KAAK;AAC7B,MAAM,gBAAgB,GAAG,SAAS;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