remark-docx

remark plugin to compile markdown to docx (Microsoft Word, Office Open XML).

Downloads in past

Stats

StarsIssuesVersionUpdatedCreatedSize
remark-docx
23120.1.69 months ago2 years agoMinified + gzip package size for remark-docx in KB

Readme

remark-docx
npm check demo
remark plugin to compile markdown to docx (Microsoft Word, Office Open XML).

🚧 WIP 🚧

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.
  • x paragraph
  • x heading
  • x thematicBreak
  • x blockquote
  • x list
  • x listItem
  • x table
  • x tableRow
  • x tableCell
  • html
  • code
  • yaml
  • toml
  • definition
  • x footnoteDefinition
  • x text
  • x emphasis
  • x strong
  • x delete
  • inlineCode
  • x break
  • x link
  • x image
  • linkReference
  • imageReference
  • x footnote
  • x footnoteReference
  • x LaTeX support with math and inlineMath (remark-math is required)

Demo

https://inokawa.github.io/remark-docx/

Install

npm install remark-docx

Usage

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);
})();

Documentation

Contribute

All contributions are welcome. If you find a problem, feel free to create an issue or a PR.

Making a Pull Request

  1. Clone this repo.
  2. Run npm install.
  3. Commit your fix.
  4. Make a PR and confirm all the CI checks passed.

Related projects