# @mdast2docx/mdast

> Extended MDAST types and custom node data for mdast2docx with support for DOCX formatting.

Latest version **0.2.5** (published 2026-10-22) · MIT license · 0 weekly downloads

## Install

```sh
npm install @mdast2docx/mdast
pnpm add @mdast2docx/mdast
yarn add @mdast2docx/mdast
bun add @mdast2docx/mdast
```

## Health

**Score 70/100 (B)** — status: active.

Positive: has types; esm support; no vulnerabilities; has provenance; recently updated; high maintenance score.

Warnings: low downloads; pre 1.0.

## Facts

| | |
|---|---|
| Version | 0.2.5 |
| Published | 2026-10-22 |
| First published | 2025-03-27 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 1 |
| Unpacked size | 6.7 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Provenance | attested (GitHub Actions) |
| GitHub stars | 1 |
| Author | Mayank Kumar Chaudhari |
| Maintainers | mayank1513 |
| Keywords | mdast, mdast extensions, custom nodes, unist custom nodes, unist, markdown, markdown-to-docx, customizable, docx formatting, text-processing, typescript, remark, unified, open-source, web-development, automation, docx, document generator, ms-word, rich text, footnotes, hyperlinks, images, mdast2docx |

## Links

- npm: https://www.npmjs.com/package/@mdast2docx/mdast
- Repository: https://github.com/md2docx/md2docx
- Homepage: https://github.com/md2docx/md2docx/blob/main/packages/mdast/README.md
- Issues: https://github.com/md2docx/md2docx/issues
- Funding: https://github.com/sponsors/md2docx
- npm.io page: https://npm.io/package/@mdast2docx/mdast

## Dependencies (1)

- [@m2d/mdast](https://npm.io/package/@m2d/mdast.md) 0.2.5

## Alternatives

- [@mdxeditor/editor](https://npm.io/package/@mdxeditor/editor.md) — 962.4K weekly downloads
- [mmdb-lib](https://npm.io/package/mmdb-lib.md) — 680.9K weekly downloads
- [playcanvas](https://npm.io/package/playcanvas.md) — 36.2K weekly downloads
- [@glw907/cairn-cms](https://npm.io/package/@glw907/cairn-cms.md) — 967 weekly downloads
- [markdown-to-confluence](https://npm.io/package/markdown-to-confluence.md) — 103 weekly downloads

## Recent versions

- 0.2.5 (latest) — 2026-10-22
- 0.2.4 — 2025-06-16
- 0.2.3 — 2025-06-08
- 0.2.2 — 2025-06-06
- 0.2.1 — 2025-06-06
- 0.2.0 — 2025-06-06
- 0.1.9 — 2025-05-30
- 0.1.8 — 2025-05-30
- 0.1.7 — 2025-05-20
- 0.1.6 — 2025-05-19
- 0.1.5 — 2025-05-19
- 0.1.4 — 2025-05-19
- 0.1.3 — 2025-05-19
- 0.1.2 — 2025-04-12
- 0.1.1 — 2025-04-07
- … 2 more at https://npm.io/package/@mdast2docx/mdast/versions

## README

# @m2d/mdast <img src="https://raw.githubusercontent.com/mayank1513/mayank1513/main/popper.png" style="height: 40px"/>

<p className="flex gap-2">
  <a href="https://github.com/md2docx/md2docx/actions/workflows/ci.yml" rel="noopener noreferrer">
    <img alt="CI" src="https://github.com/md2docx/md2docx/actions/workflows/ci.yml/badge.svg" />
  </a>
  <a href="https://codecov.io/gh/md2docx/md2docx/tree/main/packages/@m2d/mdast" rel="noopener noreferrer">
    <img alt="codecov" src="https://codecov.io/gh/md2docx/md2docx/graph/badge.svg?flag=@m2d/mdast" />
  </a> 
  <a href="https://npmjs.com/package/@m2d/mdast" rel="noopener noreferrer">
    <img alt="npm version" src="https://img.shields.io/npm/v/@m2d/mdast" />
  </a>
  <a href="https://npmjs.com/package/@m2d/mdast" rel="noopener noreferrer">
    <img alt="npm downloads" src="https://img.shields.io/npm/d18m/@m2d/mdast" />
  </a>
  <a href="https://npmjs.com/package/@m2d/mdast" rel="noopener noreferrer">
    <img alt="npm bundle size" src="https://img.shields.io/bundlephobia/minzip/@m2d/mdast" />
  </a>
  <img alt="license" src="https://img.shields.io/npm/l/@m2d/mdast" />
</p>

> @m2d/mdast: Extended Markdown & Hypertext Abstract Syntax Tree (MDAST/HAST) TypeScript type definitions and utilities for the `@m2d` DOCX compiler ecosystem.

---

## ✨ Features

- 📐 **Extended MDAST Specifications**: Augmented node definitions tailored for rich document authoring (`SVG`, `Checkbox`, `Fragment`).
- 🧱 **Enhanced Table Models**: Widened `TableCell` model supporting block content (`RootContent[]`), enabling lists, paragraphs, and quotes inside table cells.
- 🛑 **Lifecycle State Control (`EmptyNode`)**: Standardized mechanism for marking AST nodes as consumed to prevent duplicate processing across multi-plugin passes.
- 🌐 **HAST Type Definitions**: Full HTML AST definitions (`@m2d/mdast/hast`) powering HTML preprocessing and React Markdown compilation.
- 🛠️ **TypeScript Helpers**: Deep type utilities including `Optional<T>`, `Mutable<T>`, and `Immutable<T>`.

---

## 📦 Installation


> [!TIP]
> **This package (@mdast2docx/mdast) is an official alias of [@m2d/mdast](https://npmjs.com/package/@m2d/mdast).**

<details>
<summary>Why does this exist?</summary>

We provide this package to offer shorter import paths and improved discoverability. While both packages provide identical functionality, **@m2d/mdast** is the primary source of truth.
</details>

<details>
<summary>Which one should I use?</summary>

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

| Feature | @m2d/mdast | @mdast2docx/mdast |
| --- | --- | --- |
| **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) |

</details>

<details>
<summary>Maintenance & Support</summary>

> **Security:** Security audits are performed on the canonical package; this alias inherits all security patches automatically.
</details>

---



```bash
$ pnpm add @m2d/mdast
```

**_or_**

```bash
$ npm install @m2d/mdast
```

**_or_**

```bash
$ yarn add @m2d/mdast
```

---

## 🚀 Quick Start

```typescript
import type { Checkbox, Fragment, RootContent, SVG } from "@m2d/mdast";

// Strongly-typed extended SVG node
const svgNode: SVG = {
  type: "svg",
  value: "<svg viewBox='0 0 100 100'>...</svg>",
  data: {
    mermaid: "graph TD; A-->B;",
  },
};

// Strongly-typed interactive checkbox node
const checkboxNode: Checkbox = {
  type: "checkbox",
  checked: true,
};
```

---

## 📚 Deep Dive Guides

- 📐 **[Extended AST Node Specifications Guide](./docs/extended-ast-nodes.mdx)**: Specification details for `SVG`, `Checkbox`, `Fragment`, and block-level table cells.
- 🛑 **[Node Lifecycle & EmptyNode Pattern Guide](./docs/node-lifecycle-and-empty-nodes.mdx)**: Preventing duplicate node compilation and exploring TypeScript helper utilities.

---

## License

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

<hr />

<p align="center">with 💖 by <a href="https://mayankchaudhari.com" target="_blank">Mayank Kumar Chaudhari</a></p>

---
_Source: https://npm.io/package/@mdast2docx/mdast · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
