remark-docx
    TypeScript icon, indicating that this package has built-in type declarations

    0.0.7 • Public • Published

    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?

    Install

    npm i remark-docx

    DownloadsWeekly Downloads

    30

    Version

    0.0.7

    License

    MIT

    Unpacked Size

    45.5 kB

    Total Files

    9

    Last publish

    Collaborators

    • inokawa