@m2d/mdast 
@m2d/mdast: Extended Markdown & Hypertext Abstract Syntax Tree (MDAST/HAST) TypeScript type definitions and utilities for the
@m2dDOCX compiler ecosystem.
Features
- Extended MDAST Specifications: Augmented node definitions tailored for rich document authoring (
SVG,Checkbox,Fragment). - Enhanced Table Models: Widened
TableCellmodel 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>, andImmutable<T>.
Installation
This package (@mdast2docx/mdast) is an official alias of @m2d/mdast.
Why does this exist?
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.
Which one should I use?
- 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) |
Maintenance & Support
Security: Security audits are performed on the canonical package; this alias inherits all security patches automatically.
$ pnpm add @m2d/mdast
or
$ npm install @m2d/mdast
or
$ yarn add @m2d/mdast
Quick Start
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: Specification details for
SVG,Checkbox,Fragment, and block-level table cells. - Node Lifecycle & EmptyNode Pattern Guide: Preventing duplicate node compilation and exploring TypeScript helper utilities.
License
This library is licensed under the MIT open-source license.
with by Mayank Kumar Chaudhari