Skip to content

kitschpatrol/mdat

Repository files navigation

MDAT Monorepo

NPM Package mdat License: MIT

Use comments as dynamic content templates in Markdown files.

Overview

MDAT stands for the Markdown Autophagic Template system. So-named because of its ouroboros-like approach to expanding comment placeholders in-place.

It turns HTML comments in Markdown files like this:

<!-- title -->

Into this:

<!-- title -->

# mdat

<!-- /title -->

It uses sets of customizable rules to decide what to replace with what. The rule to generate the title above looks like this:

rules.ts

import type { Rules } from 'remark-mdat'
import { readPackage } from 'read-pkg'

export default {
  title: `# ${(await readPackage()).title}`,
} satisfies Rules

The mdat readme command bundles over a dozen useful rules for taking care of readme boilerplate, and adding more of your own is as easy as creating additional rules in an .mdatrc.ts file.

Packages

This repository includes two packages:

CLI tool and library implementing the Markdown Autophagic Template (MDAT) system. MDAT lets you use comments as dynamic content templates in Markdown files, making it easy to generate and update readme boilerplate.

This is the best place to get started. See the mdat readme file for much more information. It explains how to use mdat comment templates with any Markdown file, how to create your own expansion rule sets, outlines available configuration options, and documents the mdat readme which bundles handy rules for expanding common content in readme.md files.

A remark plugin implementing the Markdown Autophagic Template (MDAT) system.

See the remark-mdat readme file for more. It demonstrates how to integrate an mdat template comment expansion step in more complex remark processing pipelines. Lower-level unified mdast utility functions are also available in the remark-mdat package for surgical work on Markdown ASTs.

The future

This project will remain under major version zero until it's clear that the rule structures and so forth make sense. Breaking changes may be introduced with any point release until 1.0.

Maintainers

@kitschpatrol

Contributing

Issues and pull requests are welcome.

License

MIT © Eric Mika