mdast2docx logo Md2Docx
Version 0.2.4

Overview

Updated 5 min ago

CIcodecovnpm versionnpm downloadsnpm bundle sizelicense

@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

$ 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

License

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


with 💖 by Mayank Kumar Chaudhari

On this page