mdast2docx logo Md2Docx
Version 1.6.2

Umbrella Architecture & Package Structure

Updated 5 min ago

Why mdast2docx acts as the all-in-one distribution bundle and how to choose between umbrella vs scoped packages.

mdast2docx serves as the primary all-in-one umbrella distribution for the entire MD2DOCX ecosystem. It bundles @m2d/core along with the complete collection of official plugins, utilities, and section management tools into a single convenient package.

Umbrella Subpath Exports

By installing mdast2docx, you receive instant access to all core converters, plugins, and utilities via structured subpaths:

// 1. Core compiler and section utilities
import { toDocx, type IDocxProps } from "mdast2docx";

// 2. Section and multi-page layout models
import { Section, type ISectionProps } from "mdast2docx/section";

// 3. Official plugins bundled in a single subpath
import {
  emojiPlugin,
  htmlPlugin,
  imagePlugin,
  listPlugin,
  mathPlugin,
  mermaidPlugin,
  tablePlugin,
} from "mdast2docx/plugins";

// 4. Low-level style and Twip conversion helpers
import { convertMillimetersToTwip, mergeOptions } from "mdast2docx/utils";

Umbrella vs Scoped Packages (@m2d/*)

The MD2DOCX ecosystem offers two distinct installation strategies:

StrategyWhen to ChooseAdvantagesExample
Umbrella (mdast2docx)Standard applications, full-featured document pipelines, rapid prototypingSingle package dependency; all plugins available via mdast2docx/pluginspnpm add mdast2docx
Scoped (@m2d/*)Microservices, AWS Lambda, bundle-critical browser web appsMinimal install footprint; zero unneeded dependenciespnpm add @m2d/core @m2d/table

Here is how all plugins work together in harmony using mdast2docx:

import { toDocx } from "mdast2docx";
import {
  htmlPlugin,
  tablePlugin,
  listPlugin,
  mathPlugin,
  mermaidPlugin,
  imagePlugin,
} from "mdast2docx/plugins";
import remarkParse from "remark-parse";
import remarkGfm from "remark-gfm";
import remarkMath from "remark-math";
import { unified } from "unified";

const markdown = `...`;

const mdast = unified()
  .use(remarkParse)
  .use(remarkGfm)
  .use(remarkMath)
  .parse(markdown);

const docxBlob = await toDocx(mdast, {}, {
  plugins: [
    htmlPlugin(),     // 1. Preprocesses raw HTML into semantic MDAST nodes
    mermaidPlugin(),  // 2. Compiles mermaid blocks into SVG nodes
    imagePlugin(),    // 3. Rasterizes SVG and image URLs into Word drawings
    tablePlugin(),    // 4. Formats tables with borders and repeating headers
    listPlugin(),     // 5. Applies multi-level hierarchical decimal numbering
    mathPlugin(),     // 6. Transforms LaTeX math into native Word MathML
  ],
});

On this page