npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@markdownkit/remark-mdd

v2.0.1

Published

Remark plugins and validation for MDD (Markdown Document) format - semantic document layer for professional business documents

Readme

remark-mdd

npm version License: MIT

remark plugins for MDD (Markdown Document) format - Transform semantic markdown into professional business documents.

What is MDD?

MDD (Markdown Document) is a semantic document layer that bridges AI-generated markdown with professional business document output. It extends standard markdown with minimal semantic directives to preserve document structure and intent across formats (HTML, PDF, DOCX).

This package provides the core remark plugins and validation library. For CLI tools, see @markdownkit/mdd.

Features

  • 🔌 Remark plugins for MDD document structure and text formatting
  • Validation library with JSON Schema and TypeScript types
  • 📐 Semantic directives - letterheads, signatures, headers, footers
  • 🎯 Type-safe - Complete TypeScript definitions
  • 📦 Lightweight - Just the plugins, no CLI bloat
  • 🔧 Extensible - Build custom MDD tools

Installation

npm install @markdownkit/remark-mdd
# or
pnpm add @markdownkit/remark-mdd
# or
yarn add @markdownkit/remark-mdd

Usage

Basic Usage

import { remark } from "remark";
import remarkMddDocumentStructure from "@markdownkit/remark-mdd/plugins/document-structure";
import remarkMddTextFormatting from "@markdownkit/remark-mdd/plugins/text-formatting";
import remarkHtml from "remark-html";

const processor = remark()
  .use(remarkMddDocumentStructure)
  .use(remarkMddTextFormatting)
  .use(remarkHtml, { sanitize: false });

const result = await processor.process(`
::letterhead
ACME Corporation
123 Business Ave
::

# Invoice

Total: $1,234^00^
`);

console.log(String(result));

Using Named Exports

import {
  remarkMddDocumentStructure,
  remarkMddTextFormatting,
  remarkMdxConditional,
} from "@markdownkit/remark-mdd";

With Validation

import { validateDocument } from "@markdownkit/remark-mdd/validator";

const content = `---
title: My Invoice
document-type: invoice
date: 2024-12-15
---

# Invoice
`;

const validation = validateDocument(content);

if (!validation.valid) {
  console.error("Validation errors:", validation.errors);
}

TypeScript

import type {
  MDDFrontmatter,
  DirectiveType,
  ValidationResult,
} from "@markdownkit/remark-mdd/types";

const frontmatter: MDDFrontmatter = {
  title: "My Document",
  "document-type": "business-letter",
  date: "2024-12-15",
};

Plugins

remark-mdd-document-structure

Transforms MDD semantic directives into LaTeX-style markup that preserves document intent.

Supported directives:

  • ::letterhead ... :: - Company/organization header
  • ::header ... :: - Page header
  • ::footer ... :: - Page footer
  • ::contact-info ... :: - Contact details block
  • ::signature-block ... :: - Signature lines
  • ::page-break :: - Force page break
  • ::: section-break ::: - Section divider

Example:

::letterhead
ACME Corporation
123 Business Avenue
San Francisco, CA 94102
::

# Business Proposal

remark-mdd-text-formatting

Handles professional typography and text formatting specific to business documents.

Supported patterns:

  • text^super^<sup>super</sup> (superscripts)
  • text~sub~<sub>sub</sub> (subscripts)
  • @section-1 → Auto-linked internal references
  • Automatic section numbering (1, 1.1, 1.1.1)
  • Legal clause detection (WHEREAS, THEREFORE)

Example:

The total is $1,234^56^

See @section-2 for details.

remark-mdx-conditional

Conditional processing for MDX content (experimental).

Exports

The package provides multiple export paths for different use cases:

// Main export (all plugins)
import * from '@markdownkit/remark-mdd';

// Individual plugins
import remarkMddDocumentStructure from '@markdownkit/remark-mdd/plugins/document-structure';
import remarkMddTextFormatting from '@markdownkit/remark-mdd/plugins/text-formatting';
import remarkMdxConditional from '@markdownkit/remark-mdd/plugins/mdx-conditional';

// Validation
import { validateDocument } from '@markdownkit/remark-mdd/validator';
import { validateDirectiveEndMarker } from '@markdownkit/remark-mdd/plugin-validator';

// Schema
import schema from '@markdownkit/remark-mdd/schema';
import requirements from '@markdownkit/remark-mdd/schema/requirements';

// TypeScript types
import type { MDDFrontmatter, ValidationResult } from '@markdownkit/remark-mdd/types';

Validation

The package includes comprehensive document validation:

import { validateDocument } from "@markdownkit/remark-mdd/validator";

const result = validateDocument(content, {
  validateFrontmatterFlag: true,
  validateDirectivesFlag: true,
  validateRequirementsFlag: true,
  validateClassesFlag: true,
  strict: false,
});

console.log(result);
// {
//   valid: false,
//   errors: [...],
//   warnings: [...],
//   frontmatter: {...},
//   directives: [...],
//   directiveCounts: {...}
// }

Validation features:

  • ✅ Frontmatter schema validation (required fields, date formats)
  • ✅ Directive structure validation (end markers, nesting, duplicates)
  • ✅ Document type requirements (per-type required/recommended elements)
  • ✅ Semantic class validation (whitelist of valid CSS classes)
  • ✅ Detailed error messages with line numbers and suggestions

JSON Schema

JSON Schema definitions are included for IDE integration and validation:

import schema from "@markdownkit/remark-mdd/schema";
import requirements from "@markdownkit/remark-mdd/schema/requirements";

// Use with AJV, JSON Schema validators, etc.

VS Code integration:

{
  "yaml.schemas": {
    "node_modules/@markdownkit/remark-mdd/schema/mdd-document.schema.json#/definitions/frontmatter": "*.mdd"
  }
}

TypeScript Types

Complete TypeScript definitions are provided:

import type {
  // Document structure
  MDDFrontmatter,
  MDDDocument,
  DirectiveType,
  DocumentType,
  SemanticClass,

  // Validation
  ValidationResult,
  ValidationError,
  ValidationSeverity,

  // Plugin types
  DirectiveProcessor,
  DirectiveMatch,

  // Requirements
  DocumentTypeRequirements,
} from "@markdownkit/remark-mdd/types";

Use Cases

markdownkit Integration

// .remarkrc.js
export default {
  plugins: [
    // ... other plugins
    (await import("@markdownkit/remark-mdd/plugins/document-structure"))
      .default,
    (await import("@markdownkit/remark-mdd/plugins/text-formatting")).default,
  ],
};

Custom Build Tool

import { unified } from "unified";
import remarkParse from "remark-parse";
import remarkMddDocumentStructure from "@markdownkit/remark-mdd/plugins/document-structure";
import remarkMddTextFormatting from "@markdownkit/remark-mdd/plugins/text-formatting";
import { validateDocument } from "@markdownkit/remark-mdd/validator";

async function processDocument(content) {
  // Validate first
  const validation = validateDocument(content);
  if (!validation.valid) {
    throw new Error(
      `Validation failed: ${validation.errors.map((e) => e.message).join(", ")}`,
    );
  }

  // Process with remark
  const result = await unified()
    .use(remarkParse)
    .use(remarkMddDocumentStructure)
    .use(remarkMddTextFormatting)
    .process(content);

  return String(result);
}

Anasa Knowledge Base Integration

import {
  remarkMddDocumentStructure,
  remarkMddTextFormatting,
} from "@markdownkit/remark-mdd";

// Add MDD support to your editor pipeline
editor.use(remarkMddDocumentStructure);
editor.use(remarkMddTextFormatting);

Document Types

MDD supports 54+ professional document types with type-specific validation:

business-letter, business-proposal, invoice, proposal, contract,
legal-contract, agreement, memorandum, memo, report, legal-notice,
legal-guide, terms-of-service, privacy-policy, nda,
employment-contract, purchase-order, quote, estimate, receipt,
statement, notice, certificate, affidavit, power-of-attorney,
will, trust, deed, lease, rental-agreement, service-agreement,
consulting-agreement, partnership-agreement, operating-agreement,
shareholder-agreement, articles-of-incorporation, bylaws,
resolution, minutes, policy, procedure, manual, guide,
specification, requirements, whitepaper, case-study, brief,
motion, complaint, answer, discovery, subpoena, summons,
warrant, order, judgment, decree, other

Each document type has specific required and recommended frontmatter fields and directives.

CLI Tools

For command-line usage with preview and validation tools, install the main package:

npm install -g @markdownkit/mdd

# Preview documents
mdd-preview document.mdd

# Validate documents
mdd-validate document.mdd

See @markdownkit/mdd for CLI documentation.

Documentation

Related Packages

Contributing

Contributions are welcome! Please see CONTRIBUTING.md.

License

MIT © Dominikos Pritis

Changelog

See CHANGELOG.md for version history.