npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@mdast2docx/remark-docx

v1.6.0

Published

A unified plugin to prepare MDAST trees for DOCX conversion using mdast2docx.

Readme

@m2d/remark-docx

@m2d/remark-docx: Unified & Remark compiler plugin that transforms Markdown directly into Microsoft Word (.docx) documents.


✨ Features

  • 🔌 Unified & Remark Compiler: Plugs directly into unified().use(remarkDocx) to compile MDAST syntax trees into Word OpenXML.
  • 📦 Auto-Injected Plugins: Automatically configures tables, math, lists, images, emojis, and HTML plugins when none are specified.
  • 🌐 Isomorphic Execution: Runs in both browser (generating client-side Blobs) and Node.js (generating Buffers for file writing).
  • ⚙️ Configurable Outputs: Supports "blob", "buffer", "base64", and "uint8array" formats.
  • ⚡ Dual Execution APIs: Compatible with both async .process() and synchronous .processSync() pipelines.

📦 Installation

[!TIP] This package (@mdast2docx/remark-docx) is an official alias of @m2d/remark-docx.

We provide this package to offer shorter import paths and improved discoverability. While both packages provide identical functionality, @m2d/remark-docx is the primary source of truth.

  • Use @mdast2docx/remark-docx if you prefer the shorter name or specific branding or ESM Only.
  • Use @m2d/remark-docx for the most stable long-term reference and standard alignment.

| Feature | @m2d/remark-docx | @mdast2docx/remark-docx | | --- | --- | --- | | Source Code | ✅ Primary | 🔗 Proxy | | Updates | Immediate | Synchronized (Immediately) | | Bundle Size | 100% | 100% (Zero overhead) | | Format | ESM + CJS | ESM Only | | Maintenance | ✅ Primary | 🔗 Proxy (inherits) | | Security | ✅ Primary | 🔗 Proxy (inherits) |

Security: Security audits are performed on the canonical package; this alias inherits all security patches automatically.


$ pnpm add @m2d/remark-docx docx unified remark-parse remark-gfm

or

$ npm install @m2d/remark-docx docx unified remark-parse remark-gfm

or

$ yarn add @m2d/remark-docx docx unified remark-parse remark-gfm

🚀 Quick Start

Browser (Download as DOCX)

import { unified } from "unified";
import remarkParse from "remark-parse";
import remarkGfm from "remark-gfm";
import { remarkDocx } from "@m2d/remark-docx";

const processor = unified()
  .use(remarkParse)
  .use(remarkGfm)
  .use(remarkDocx, "blob");

const file = await processor.process(
  "# Hello World\n\nExported directly to Word!",
);
const blob = (await file.result) as Blob;

// Trigger browser download
const url = URL.createObjectURL(blob);
const link = document.createElement("a");
link.href = url;
link.download = "document.docx";
link.click();
URL.revokeObjectURL(url);

Node.js (with Native Images & Mermaid Support)

For Node.js environments, use @m2d/remark-docx-node to automatically wire native server-side image resolution (@m2d/image-node) and diagram rendering (@m2d/mermaid-node):

import fs from "node:fs/promises";
import { unified } from "unified";
import remarkParse from "remark-parse";
import remarkGfm from "remark-gfm";
import { remarkDocx } from "@m2d/remark-docx-node";

const processor = unified()
  .use(remarkParse)
  .use(remarkGfm)
  .use(remarkDocx, "buffer");

const file = await processor.process(
  "# Server Report\n\nWritten via Node.js with native image and Mermaid rasterization.",
);
const buffer = (await file.result) as Buffer;

await fs.writeFile("report.docx", buffer);

⚙️ Plugin Signature

import { OutputType } from "docx";
import { IDocxProps, ISectionProps } from "mdast2docx";

remarkDocx(
  outputType?: "blob" | "buffer" | "base64" | "uint8array", // Default: "blob"
  docxProps?: IDocxProps,                                  // Global Word document options (title, styles, definitionsScope: "shared" | "section")
  sectionProps?: ISectionProps,                            // Section margins, headers, and plugins
  pluginProps?: {                                          // Options passed to auto-injected plugins
    table?: TablePluginOptions;
    list?: ListPluginOptions;
    mermaid?: MermaidPluginOptions;
    image?: ImagePluginOptions;
    emoji?: EmojiPluginOptions;
  }
);

📚 Deep Dive Guides


License

This library is licensed under the MIT open-source license.