JSPM

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

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

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 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.

  • 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)

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>.
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?