JSPM

  • Created
  • Published
  • Downloads 17661
  • Score
    100M100P100Q137978F
  • License MIT

remark plugin to transform markdown to docx.

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

npm check demo

remark plugin to transform 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, { Packer } from "remark-docx";
import { saveAs } from "file-saver";

const processor = unified().use(markdown).use(docx);

const text = "# hello world";

(async () => {
  const doc = await processor.process(text);
  const blob = await Packer.toBlob(doc.result);
  saveAs(blob, "example.docx");
})();

Node.js

import { unified } from "unified";
import markdown from "remark-parse";
import docx, { Packer } from "remark-docx";
import * as fs from "fs";

const processor = unified().use(markdown).use(docx);

const text = "# hello world";

(async () => {
  const doc = await processor.process(text);
  const buffer = await Packer.toBuffer(doc.result);
  fs.writeFileSync("example.docx", buffer);
})();

Options

Key Default Type Description
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.