Package Exports
- remark-docx
- remark-docx/lib/index.js
- remark-docx/lib/index.mjs
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (remark-docx) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
remark-docx
remark plugin to compile markdown to docx.
🚧 WIP 🚧
The goal is to support all nodes in mdast syntax tree, but currently transformation and stylings may not be well.
If you have some feature requests or improvements, please create a issue or PR.
Demo
https://inokawa.github.io/remark-docx/
Install
npm install remark-docxUsage
Browser
import { unified } from "unified";
import markdown from "remark-parse";
import docx from "remark-docx";
import { saveAs } from "file-saver";
const processor = unified().use(markdown).use(docx, { output: "blob" });
const text = "# hello world";
(async () => {
const doc = await processor.process(text);
const blob = await doc.result;
saveAs(blob, "example.docx");
})();Node.js
import { unified } from "unified";
import markdown from "remark-parse";
import docx from "remark-docx";
import * as fs from "fs";
const processor = unified().use(markdown).use(docx, { output: "buffer" });
const text = "# hello world";
(async () => {
const doc = await processor.process(text);
const buffer = await doc.result;
fs.writeFileSync("example.docx", buffer);
})();Options
| Key | Default | Type | Description |
|---|---|---|---|
| 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. |
| docProperties | undefined | object | Override properties of document. |
| imageResolver | undefined | ImageResolver | You must set if your markdown includes images. See example for browser and Node.js. |