@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
$ 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