npm.io
0.2.5 • Published 23h ago

@m2d/mdast

Licence
MIT
Version
0.2.5
Deps
1
Size
15 kB
Vulns
0
Weekly
0
Stars
1

@m2d/mdast

CI codecov npm version npm downloads npm bundle size license

@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

Keywords