remark-docx

remark plugin to compile markdown to docx.

Stats

StarsIssuesVersionUpdatedCreatedSize
remark-docx
110.0.77 days ago10 days agoMinified + gzip package size for remark-docx in KB

Readme

remark-docx

npm check demo

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

Options

Key Default Type Description
output "buffer" "buffer" "blob" Set output type of VFile.result. buffer is Promise<Buffer>. blob is Promise<Blob>.for testing.
imageResolver undefined ImageResolver? You must set if your markdown includes images. See example for browser and Node.js.
title undefined string?
subject undefined string?
creator undefined string?
keywords undefined string?
description undefined string?
lastModifiedBy undefined string?
revision undefined number?
styles undefined IStylesOptions?
background undefined IDocumentBackgroundOptions?

If you find any bugs or have a feature request, please open an issue on github!

The npm package download data comes from npm's download counts api and package details come from npms.io.