remark plugin to compile markdown to docx (Microsoft Word, Office Open XML).
This project is aiming 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.
- paragraph
- heading
- thematicBreak
- blockquote
- list
- listItem
- table
- tableRow
- tableCell
- html
- code
- yaml
- toml
- definition
- footnoteDefinition
- text
- emphasis
- strong
- delete
- inlineCode
- break
- link
- image
- linkReference
- imageReference
- footnote
- footnoteReference
- LaTeX support with math and inlineMath (remark-math is required)
https://inokawa.github.io/remark-docx/
npm install remark-docx
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");
})();
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);
})();
All contributions are welcome. If you find a problem, feel free to create an issue or a PR.
- Clone this repo.
- Run
npm install
. - Commit your fix.
- Make a PR and confirm all the CI checks passed.