remark-docx 0.0.2 → 0.0.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  ![npm](https://img.shields.io/npm/v/remark-docx) ![check](https://github.com/inokawa/remark-docx/workflows/check/badge.svg) ![demo](https://github.com/inokawa/remark-docx/workflows/demo/badge.svg)
4
4
 
5
- [remark](https://github.com/remarkjs/remark) plugin to transform markdown to docx.
5
+ [remark](https://github.com/remarkjs/remark) plugin to compile markdown to docx.
6
6
 
7
7
  ### 🚧 WIP 🚧
8
8
 
@@ -27,16 +27,16 @@ npm install remark-docx
27
27
  ```javascript
28
28
  import { unified } from "unified";
29
29
  import markdown from "remark-parse";
30
- import docx, { Packer } from "remark-docx";
30
+ import docx from "remark-docx";
31
31
  import { saveAs } from "file-saver";
32
32
 
33
- const processor = unified().use(markdown).use(docx);
33
+ const processor = unified().use(markdown).use(docx, { output: "blob" });
34
34
 
35
35
  const text = "# hello world";
36
36
 
37
37
  (async () => {
38
38
  const doc = await processor.process(text);
39
- const blob = await Packer.toBlob(doc.result);
39
+ const blob = await doc.result;
40
40
  saveAs(blob, "example.docx");
41
41
  })();
42
42
  ```
@@ -46,23 +46,32 @@ const text = "# hello world";
46
46
  ```javascript
47
47
  import { unified } from "unified";
48
48
  import markdown from "remark-parse";
49
- import docx, { Packer } from "remark-docx";
49
+ import docx from "remark-docx";
50
50
  import * as fs from "fs";
51
51
 
52
- const processor = unified().use(markdown).use(docx);
52
+ const processor = unified().use(markdown).use(docx, { output: "buffer" });
53
53
 
54
54
  const text = "# hello world";
55
55
 
56
56
  (async () => {
57
57
  const doc = await processor.process(text);
58
- const buffer = await Packer.toBuffer(doc.result);
58
+ const buffer = await doc.result;
59
59
  fs.writeFileSync("example.docx", buffer);
60
60
  })();
61
61
  ```
62
62
 
63
63
  ## Options
64
64
 
65
- | Key | Default | Type | Description |
66
- | ------------- | --------- | ------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
67
- | docProperties | undefined | object | Override properties of document. |
68
- | imageResolver | undefined | ImageResolver | **You must set** if your markdown includes images. See example for [browser](https://github.com/inokawa/remark-docx/blob/main/stories/playground.stories.tsx) and [Node.js](https://github.com/inokawa/remark-docx/blob/main/src/index.spec.ts). |
65
+ | Key | Default | Type | Description |
66
+ | -------------- | --------- | --------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
67
+ | output | "buffer" | `"buffer"` `"blob"` `"raw"` | Set output type of `VFile.result`. `buffer` is `Promise<ArrayBuffer>`. `blob` is `Promise<Blob>`. `raw` is internal data for testing. |
68
+ | imageResolver | undefined | ImageResolver? | **You must set** if your markdown includes images. See example for [browser](https://github.com/inokawa/remark-docx/blob/main/stories/playground.stories.tsx) and [Node.js](https://github.com/inokawa/remark-docx/blob/main/src/index.spec.ts). |
69
+ | title | undefined | string? | |
70
+ | subject | undefined | string? | |
71
+ | creator | undefined | string? | |
72
+ | keywords | undefined | string? | |
73
+ | description | undefined | string? | |
74
+ | lastModifiedBy | undefined | string? | |
75
+ | revision | undefined | number? | |
76
+ | styles | undefined | IStylesOptions? | |
77
+ | background | undefined | IDocumentBackgroundOptions? | |
package/lib/index.d.ts CHANGED
@@ -1,3 +1,2 @@
1
1
  export { default } from "./plugin";
2
2
  export type { Options as DocxOptions } from "./plugin";
3
- export { Packer } from "docx";
package/lib/index.js CHANGED
@@ -1,7 +1,5 @@
1
1
  'use strict';
2
2
 
3
- Object.defineProperty(exports, '__esModule', { value: true });
4
-
5
3
  var unistUtilVisit = require('unist-util-visit');
6
4
  var docx = require('docx');
7
5
 
@@ -157,47 +155,65 @@ var DEFAULT_NUMBERINGS = [
157
155
  var error = function (message) {
158
156
  throw new Error(message);
159
157
  };
160
- function mdastToDocx(node, opts, images) {
161
- return buildDocxRoot(node, opts, images);
162
- }
163
- function buildDocxRoot(root, opts, images) {
158
+ function mdastToDocx(node, _a, images) {
159
+ var output = _a.output, title = _a.title, subject = _a.subject, creator = _a.creator, keywords = _a.keywords, description = _a.description, lastModifiedBy = _a.lastModifiedBy, revision = _a.revision, styles = _a.styles, background = _a.background;
164
160
  var ctx = { deco: {}, images: images };
165
- var nodes = convertNodes(root.children, ctx, opts);
166
- return new docx__namespace.Document(__assign(__assign({}, opts.docProperties), { sections: [{ children: nodes }], numbering: {
161
+ var nodes = convertNodes(node.children, ctx);
162
+ var doc = new docx__namespace.Document({
163
+ title: title,
164
+ subject: subject,
165
+ creator: creator,
166
+ keywords: keywords,
167
+ description: description,
168
+ lastModifiedBy: lastModifiedBy,
169
+ revision: revision,
170
+ styles: styles,
171
+ background: background,
172
+ sections: [{ children: nodes }],
173
+ numbering: {
167
174
  config: [
168
175
  {
169
176
  reference: ORDERED_LIST_REF,
170
177
  levels: DEFAULT_NUMBERINGS,
171
178
  },
172
179
  ],
173
- } }));
180
+ },
181
+ });
182
+ switch (output !== null && output !== void 0 ? output : "buffer") {
183
+ case "buffer":
184
+ return docx.Packer.toBuffer(doc);
185
+ case "blob":
186
+ return docx.Packer.toBlob(doc);
187
+ case "raw":
188
+ return doc;
189
+ }
174
190
  }
175
- function convertNodes(nodes, ctx, opts) {
191
+ function convertNodes(nodes, ctx) {
176
192
  var _a;
177
193
  var results = [];
178
194
  for (var _i = 0, nodes_1 = nodes; _i < nodes_1.length; _i++) {
179
195
  var node = nodes_1[_i];
180
196
  switch (node.type) {
181
197
  case "paragraph":
182
- results.push(buildParagraph(node, ctx, opts));
198
+ results.push(buildParagraph(node, ctx));
183
199
  break;
184
200
  case "heading":
185
- results.push(buildHeading(node, ctx, opts));
201
+ results.push(buildHeading(node, ctx));
186
202
  break;
187
203
  case "thematicBreak":
188
204
  results.push(buildThematicBreak(node));
189
205
  break;
190
206
  case "blockquote":
191
- results.push.apply(results, buildBlockquote(node, ctx, opts));
207
+ results.push.apply(results, buildBlockquote(node, ctx));
192
208
  break;
193
209
  case "list":
194
- results.push.apply(results, buildList(node, ctx, opts));
210
+ results.push.apply(results, buildList(node, ctx));
195
211
  break;
196
212
  case "listItem":
197
213
  error("unreachable");
198
214
  break;
199
215
  case "table":
200
- results.push(buildTable(node, ctx, opts));
216
+ results.push(buildTable(node, ctx));
201
217
  break;
202
218
  case "tableRow":
203
219
  error("unreachable");
@@ -230,7 +246,7 @@ function convertNodes(nodes, ctx, opts) {
230
246
  case "strong":
231
247
  case "delete": {
232
248
  var type = node.type, children = node.children;
233
- results.push.apply(results, convertNodes(children, __assign(__assign({}, ctx), { deco: __assign(__assign({}, ctx.deco), (_a = {}, _a[type] = true, _a)) }), opts));
249
+ results.push.apply(results, convertNodes(children, __assign(__assign({}, ctx), { deco: __assign(__assign({}, ctx.deco), (_a = {}, _a[type] = true, _a)) })));
234
250
  break;
235
251
  }
236
252
  case "inlineCode":
@@ -241,7 +257,7 @@ function convertNodes(nodes, ctx, opts) {
241
257
  results.push(buildBreak(node));
242
258
  break;
243
259
  case "link":
244
- results.push(buildLink(node, ctx, opts));
260
+ results.push(buildLink(node, ctx));
245
261
  break;
246
262
  case "image":
247
263
  results.push(buildImage(node, ctx.images));
@@ -253,7 +269,7 @@ function convertNodes(nodes, ctx, opts) {
253
269
  // FIXME: unimplemented
254
270
  break;
255
271
  case "footnote":
256
- results.push(buildFootnote(node, ctx, opts));
272
+ results.push(buildFootnote(node, ctx));
257
273
  break;
258
274
  case "footnoteReference":
259
275
  // FIXME: unimplemented
@@ -268,10 +284,10 @@ function convertNodes(nodes, ctx, opts) {
268
284
  }
269
285
  return results;
270
286
  }
271
- function buildParagraph(_a, ctx, opts) {
287
+ function buildParagraph(_a, ctx) {
272
288
  _a.type; var children = _a.children;
273
289
  var list = ctx.list;
274
- return new docx__namespace.Paragraph(__assign({ children: convertNodes(children, ctx, opts) }, (list &&
290
+ return new docx__namespace.Paragraph(__assign({ children: convertNodes(children, ctx) }, (list &&
275
291
  (list.ordered
276
292
  ? {
277
293
  numbering: {
@@ -285,7 +301,7 @@ function buildParagraph(_a, ctx, opts) {
285
301
  },
286
302
  }))));
287
303
  }
288
- function buildHeading(_a, ctx, opts) {
304
+ function buildHeading(_a, ctx) {
289
305
  _a.type; var children = _a.children, depth = _a.depth;
290
306
  var heading;
291
307
  switch (depth) {
@@ -310,7 +326,7 @@ function buildHeading(_a, ctx, opts) {
310
326
  }
311
327
  return new docx__namespace.Paragraph({
312
328
  heading: heading,
313
- children: convertNodes(children, ctx, opts),
329
+ children: convertNodes(children, ctx),
314
330
  });
315
331
  }
316
332
  function buildThematicBreak(_a) {
@@ -319,27 +335,27 @@ function buildThematicBreak(_a) {
319
335
  thematicBreak: true,
320
336
  });
321
337
  }
322
- function buildBlockquote(_a, ctx, opts) {
338
+ function buildBlockquote(_a, ctx) {
323
339
  _a.type; var children = _a.children;
324
340
  // FIXME: do nothing for now
325
- return convertNodes(children, ctx, opts);
341
+ return convertNodes(children, ctx);
326
342
  }
327
- function buildList(_a, ctx, opts) {
343
+ function buildList(_a, ctx) {
328
344
  _a.type; var children = _a.children, ordered = _a.ordered; _a.start; _a.spread;
329
345
  var list = {
330
346
  level: ctx.list ? ctx.list.level + 1 : 0,
331
347
  ordered: !!ordered,
332
348
  };
333
349
  return children.reduce(function (acc, item) {
334
- acc.push.apply(acc, buildListItem(item, __assign(__assign({}, ctx), { list: list }), opts));
350
+ acc.push.apply(acc, buildListItem(item, __assign(__assign({}, ctx), { list: list })));
335
351
  return acc;
336
352
  }, []);
337
353
  }
338
- function buildListItem(_a, ctx, opts) {
354
+ function buildListItem(_a, ctx) {
339
355
  _a.type; var children = _a.children; _a.checked; _a.spread;
340
- return convertNodes(children, ctx, opts);
356
+ return convertNodes(children, ctx);
341
357
  }
342
- function buildTable(_a, ctx, opts) {
358
+ function buildTable(_a, ctx) {
343
359
  _a.type; var children = _a.children, align = _a.align;
344
360
  var cellAligns = align === null || align === void 0 ? void 0 : align.map(function (a) {
345
361
  switch (a) {
@@ -355,25 +371,25 @@ function buildTable(_a, ctx, opts) {
355
371
  });
356
372
  return new docx__namespace.Table({
357
373
  rows: children.map(function (r) {
358
- return buildTableRow(r, ctx, opts, cellAligns);
374
+ return buildTableRow(r, ctx, cellAligns);
359
375
  }),
360
376
  });
361
377
  }
362
- function buildTableRow(_a, ctx, opts, cellAligns) {
378
+ function buildTableRow(_a, ctx, cellAligns) {
363
379
  _a.type; var children = _a.children;
364
380
  return new docx__namespace.TableRow({
365
381
  children: children.map(function (c, i) {
366
- return buildTableCell(c, ctx, opts, cellAligns === null || cellAligns === void 0 ? void 0 : cellAligns[i]);
382
+ return buildTableCell(c, ctx, cellAligns === null || cellAligns === void 0 ? void 0 : cellAligns[i]);
367
383
  }),
368
384
  });
369
385
  }
370
- function buildTableCell(_a, ctx, opts, align) {
386
+ function buildTableCell(_a, ctx, align) {
371
387
  _a.type; var children = _a.children;
372
388
  return new docx__namespace.TableCell({
373
389
  children: [
374
390
  new docx__namespace.Paragraph({
375
391
  alignment: align,
376
- children: convertNodes(children, ctx, opts),
392
+ children: convertNodes(children, ctx),
377
393
  }),
378
394
  ],
379
395
  });
@@ -416,11 +432,11 @@ function buildBreak(_a) {
416
432
  _a.type;
417
433
  return new docx__namespace.TextRun({ text: "", break: 1 });
418
434
  }
419
- function buildLink(_a, ctx, opts) {
435
+ function buildLink(_a, ctx) {
420
436
  _a.type; var children = _a.children, url = _a.url; _a.title;
421
437
  return new docx__namespace.ExternalHyperlink({
422
438
  link: url,
423
- children: convertNodes(children, ctx, opts),
439
+ children: convertNodes(children, ctx),
424
440
  });
425
441
  }
426
442
  function buildImage(_a, images) {
@@ -437,11 +453,11 @@ function buildImage(_a, images) {
437
453
  },
438
454
  });
439
455
  }
440
- function buildFootnote(_a, ctx, opts) {
456
+ function buildFootnote(_a, ctx) {
441
457
  _a.type; var children = _a.children;
442
458
  // FIXME: transform to paragraph for now
443
459
  return new docx__namespace.Paragraph({
444
- children: convertNodes(children, ctx, opts),
460
+ children: convertNodes(children, ctx),
445
461
  });
446
462
  }
447
463
 
@@ -484,8 +500,4 @@ var plugin = function (opts) {
484
500
  }); };
485
501
  };
486
502
 
487
- Object.defineProperty(exports, 'Packer', {
488
- enumerable: true,
489
- get: function () { return docx.Packer; }
490
- });
491
- exports["default"] = plugin;
503
+ module.exports = plugin;
package/lib/index.mjs CHANGED
@@ -1,7 +1,6 @@
1
1
  import { visit } from 'unist-util-visit';
2
2
  import * as docx from 'docx';
3
- import { convertInchesToTwip } from 'docx';
4
- export { Packer } from 'docx';
3
+ import { convertInchesToTwip, Packer } from 'docx';
5
4
 
6
5
  /*! *****************************************************************************
7
6
  Copyright (c) Microsoft Corporation.
@@ -135,47 +134,65 @@ var DEFAULT_NUMBERINGS = [
135
134
  var error = function (message) {
136
135
  throw new Error(message);
137
136
  };
138
- function mdastToDocx(node, opts, images) {
139
- return buildDocxRoot(node, opts, images);
140
- }
141
- function buildDocxRoot(root, opts, images) {
137
+ function mdastToDocx(node, _a, images) {
138
+ var output = _a.output, title = _a.title, subject = _a.subject, creator = _a.creator, keywords = _a.keywords, description = _a.description, lastModifiedBy = _a.lastModifiedBy, revision = _a.revision, styles = _a.styles, background = _a.background;
142
139
  var ctx = { deco: {}, images: images };
143
- var nodes = convertNodes(root.children, ctx, opts);
144
- return new docx.Document(__assign(__assign({}, opts.docProperties), { sections: [{ children: nodes }], numbering: {
140
+ var nodes = convertNodes(node.children, ctx);
141
+ var doc = new docx.Document({
142
+ title: title,
143
+ subject: subject,
144
+ creator: creator,
145
+ keywords: keywords,
146
+ description: description,
147
+ lastModifiedBy: lastModifiedBy,
148
+ revision: revision,
149
+ styles: styles,
150
+ background: background,
151
+ sections: [{ children: nodes }],
152
+ numbering: {
145
153
  config: [
146
154
  {
147
155
  reference: ORDERED_LIST_REF,
148
156
  levels: DEFAULT_NUMBERINGS,
149
157
  },
150
158
  ],
151
- } }));
159
+ },
160
+ });
161
+ switch (output !== null && output !== void 0 ? output : "buffer") {
162
+ case "buffer":
163
+ return Packer.toBuffer(doc);
164
+ case "blob":
165
+ return Packer.toBlob(doc);
166
+ case "raw":
167
+ return doc;
168
+ }
152
169
  }
153
- function convertNodes(nodes, ctx, opts) {
170
+ function convertNodes(nodes, ctx) {
154
171
  var _a;
155
172
  var results = [];
156
173
  for (var _i = 0, nodes_1 = nodes; _i < nodes_1.length; _i++) {
157
174
  var node = nodes_1[_i];
158
175
  switch (node.type) {
159
176
  case "paragraph":
160
- results.push(buildParagraph(node, ctx, opts));
177
+ results.push(buildParagraph(node, ctx));
161
178
  break;
162
179
  case "heading":
163
- results.push(buildHeading(node, ctx, opts));
180
+ results.push(buildHeading(node, ctx));
164
181
  break;
165
182
  case "thematicBreak":
166
183
  results.push(buildThematicBreak(node));
167
184
  break;
168
185
  case "blockquote":
169
- results.push.apply(results, buildBlockquote(node, ctx, opts));
186
+ results.push.apply(results, buildBlockquote(node, ctx));
170
187
  break;
171
188
  case "list":
172
- results.push.apply(results, buildList(node, ctx, opts));
189
+ results.push.apply(results, buildList(node, ctx));
173
190
  break;
174
191
  case "listItem":
175
192
  error("unreachable");
176
193
  break;
177
194
  case "table":
178
- results.push(buildTable(node, ctx, opts));
195
+ results.push(buildTable(node, ctx));
179
196
  break;
180
197
  case "tableRow":
181
198
  error("unreachable");
@@ -208,7 +225,7 @@ function convertNodes(nodes, ctx, opts) {
208
225
  case "strong":
209
226
  case "delete": {
210
227
  var type = node.type, children = node.children;
211
- results.push.apply(results, convertNodes(children, __assign(__assign({}, ctx), { deco: __assign(__assign({}, ctx.deco), (_a = {}, _a[type] = true, _a)) }), opts));
228
+ results.push.apply(results, convertNodes(children, __assign(__assign({}, ctx), { deco: __assign(__assign({}, ctx.deco), (_a = {}, _a[type] = true, _a)) })));
212
229
  break;
213
230
  }
214
231
  case "inlineCode":
@@ -219,7 +236,7 @@ function convertNodes(nodes, ctx, opts) {
219
236
  results.push(buildBreak(node));
220
237
  break;
221
238
  case "link":
222
- results.push(buildLink(node, ctx, opts));
239
+ results.push(buildLink(node, ctx));
223
240
  break;
224
241
  case "image":
225
242
  results.push(buildImage(node, ctx.images));
@@ -231,7 +248,7 @@ function convertNodes(nodes, ctx, opts) {
231
248
  // FIXME: unimplemented
232
249
  break;
233
250
  case "footnote":
234
- results.push(buildFootnote(node, ctx, opts));
251
+ results.push(buildFootnote(node, ctx));
235
252
  break;
236
253
  case "footnoteReference":
237
254
  // FIXME: unimplemented
@@ -246,10 +263,10 @@ function convertNodes(nodes, ctx, opts) {
246
263
  }
247
264
  return results;
248
265
  }
249
- function buildParagraph(_a, ctx, opts) {
266
+ function buildParagraph(_a, ctx) {
250
267
  _a.type; var children = _a.children;
251
268
  var list = ctx.list;
252
- return new docx.Paragraph(__assign({ children: convertNodes(children, ctx, opts) }, (list &&
269
+ return new docx.Paragraph(__assign({ children: convertNodes(children, ctx) }, (list &&
253
270
  (list.ordered
254
271
  ? {
255
272
  numbering: {
@@ -263,7 +280,7 @@ function buildParagraph(_a, ctx, opts) {
263
280
  },
264
281
  }))));
265
282
  }
266
- function buildHeading(_a, ctx, opts) {
283
+ function buildHeading(_a, ctx) {
267
284
  _a.type; var children = _a.children, depth = _a.depth;
268
285
  var heading;
269
286
  switch (depth) {
@@ -288,7 +305,7 @@ function buildHeading(_a, ctx, opts) {
288
305
  }
289
306
  return new docx.Paragraph({
290
307
  heading: heading,
291
- children: convertNodes(children, ctx, opts),
308
+ children: convertNodes(children, ctx),
292
309
  });
293
310
  }
294
311
  function buildThematicBreak(_a) {
@@ -297,27 +314,27 @@ function buildThematicBreak(_a) {
297
314
  thematicBreak: true,
298
315
  });
299
316
  }
300
- function buildBlockquote(_a, ctx, opts) {
317
+ function buildBlockquote(_a, ctx) {
301
318
  _a.type; var children = _a.children;
302
319
  // FIXME: do nothing for now
303
- return convertNodes(children, ctx, opts);
320
+ return convertNodes(children, ctx);
304
321
  }
305
- function buildList(_a, ctx, opts) {
322
+ function buildList(_a, ctx) {
306
323
  _a.type; var children = _a.children, ordered = _a.ordered; _a.start; _a.spread;
307
324
  var list = {
308
325
  level: ctx.list ? ctx.list.level + 1 : 0,
309
326
  ordered: !!ordered,
310
327
  };
311
328
  return children.reduce(function (acc, item) {
312
- acc.push.apply(acc, buildListItem(item, __assign(__assign({}, ctx), { list: list }), opts));
329
+ acc.push.apply(acc, buildListItem(item, __assign(__assign({}, ctx), { list: list })));
313
330
  return acc;
314
331
  }, []);
315
332
  }
316
- function buildListItem(_a, ctx, opts) {
333
+ function buildListItem(_a, ctx) {
317
334
  _a.type; var children = _a.children; _a.checked; _a.spread;
318
- return convertNodes(children, ctx, opts);
335
+ return convertNodes(children, ctx);
319
336
  }
320
- function buildTable(_a, ctx, opts) {
337
+ function buildTable(_a, ctx) {
321
338
  _a.type; var children = _a.children, align = _a.align;
322
339
  var cellAligns = align === null || align === void 0 ? void 0 : align.map(function (a) {
323
340
  switch (a) {
@@ -333,25 +350,25 @@ function buildTable(_a, ctx, opts) {
333
350
  });
334
351
  return new docx.Table({
335
352
  rows: children.map(function (r) {
336
- return buildTableRow(r, ctx, opts, cellAligns);
353
+ return buildTableRow(r, ctx, cellAligns);
337
354
  }),
338
355
  });
339
356
  }
340
- function buildTableRow(_a, ctx, opts, cellAligns) {
357
+ function buildTableRow(_a, ctx, cellAligns) {
341
358
  _a.type; var children = _a.children;
342
359
  return new docx.TableRow({
343
360
  children: children.map(function (c, i) {
344
- return buildTableCell(c, ctx, opts, cellAligns === null || cellAligns === void 0 ? void 0 : cellAligns[i]);
361
+ return buildTableCell(c, ctx, cellAligns === null || cellAligns === void 0 ? void 0 : cellAligns[i]);
345
362
  }),
346
363
  });
347
364
  }
348
- function buildTableCell(_a, ctx, opts, align) {
365
+ function buildTableCell(_a, ctx, align) {
349
366
  _a.type; var children = _a.children;
350
367
  return new docx.TableCell({
351
368
  children: [
352
369
  new docx.Paragraph({
353
370
  alignment: align,
354
- children: convertNodes(children, ctx, opts),
371
+ children: convertNodes(children, ctx),
355
372
  }),
356
373
  ],
357
374
  });
@@ -394,11 +411,11 @@ function buildBreak(_a) {
394
411
  _a.type;
395
412
  return new docx.TextRun({ text: "", break: 1 });
396
413
  }
397
- function buildLink(_a, ctx, opts) {
414
+ function buildLink(_a, ctx) {
398
415
  _a.type; var children = _a.children, url = _a.url; _a.title;
399
416
  return new docx.ExternalHyperlink({
400
417
  link: url,
401
- children: convertNodes(children, ctx, opts),
418
+ children: convertNodes(children, ctx),
402
419
  });
403
420
  }
404
421
  function buildImage(_a, images) {
@@ -415,11 +432,11 @@ function buildImage(_a, images) {
415
432
  },
416
433
  });
417
434
  }
418
- function buildFootnote(_a, ctx, opts) {
435
+ function buildFootnote(_a, ctx) {
419
436
  _a.type; var children = _a.children;
420
437
  // FIXME: transform to paragraph for now
421
438
  return new docx.Paragraph({
422
- children: convertNodes(children, ctx, opts),
439
+ children: convertNodes(children, ctx),
423
440
  });
424
441
  }
425
442
 
@@ -11,7 +11,7 @@ export declare type ImageData = {
11
11
  };
12
12
  export declare type ImageResolver = (url: string) => Promise<ImageData> | ImageData;
13
13
  export declare type Opts = {
14
- docProperties?: Omit<IPropertiesOptions, "sections" | "numbering">;
14
+ output?: "buffer" | "blob" | "raw";
15
15
  imageResolver?: ImageResolver;
16
- };
17
- export declare function mdastToDocx(node: mdast.Root, opts: Opts, images: ImageDataMap): docx.File;
16
+ } & Pick<IPropertiesOptions, "title" | "subject" | "creator" | "keywords" | "description" | "lastModifiedBy" | "revision" | "styles" | "background">;
17
+ export declare function mdastToDocx(node: mdast.Root, { output, title, subject, creator, keywords, description, lastModifiedBy, revision, styles, background, }: Opts, images: ImageDataMap): Promise<any> | docx.File;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "remark-docx",
3
- "version": "0.0.2",
4
- "description": "remark plugin to transform markdown to docx.",
3
+ "version": "0.0.6",
4
+ "description": "remark plugin to compile markdown to docx.",
5
5
  "main": "lib/index.js",
6
6
  "module": "lib/index.mjs",
7
7
  "types": "lib/index.d.ts",