# MDFX

> For agents: start with the [agent guide](https://ratstack.sh/llms.txt). Every page is Markdown by default; add `Accept: text/html` for HTML.

New on /news: [Pleat 0.2 moves its typed styles to Effect UI](/news).

## What it does

MDFX is Markdown with YAML frontmatter, GitHub-style alerts, and registered component tags. It checks component props against a [schema](/lore/schemas-define-the-boundary) before a host renders them. It can also emit ordinary Markdown for readers and agents.

## The standard

- Put each component tag on its own line, with at most three leading spaces and no tabs. Use quoted strings for props and Markdown for children.
- Use a GitHub-style alert for a callout. The compiler puts the tone and body in a typed node.
- Give a heading, paragraph, or list item a stable ID with a trailing `{#claim}` marker. The compiler keeps the ID on the block and removes the marker from rendered prose. A `Ref` accepts a Wiki target or the legacy page and ID pair. It can stand alone inside a list item or blockquote.
- Put examples of tags and expressions in code spans or fences. The compiler does not run document scripts or expressions.
- Read all diagnostics before publishing. Each names the file, line, column, and repair. Prop errors also name the schema path.
- Converting a legacy file must preserve its content. The codemod wraps prose placeholders, escapes malformed alerts as ordinary quotes, and reports what still needs a hand edit. It leaves raw HTML alone.
- A Svelte host must pair `remarkMdfx` with `rehypeMdfxEscape`. Run the latter after slug and table-of-contents plugins so they can still read ordinary prose and inline code.

## How to check

Existing MCP resource keys keep their `.svx` suffix. The keys identify published resources; the `.mdfx` path identifies the file to edit.

Rat-stack pins the [built MDFX release](https://github.com/joelhooks/mdfx/tree/ade80a77fc9e074c9dc0a1a92b2b78dd76e882f7). Each version bump pins a new release commit.

- Run `pnpm --filter @rat-stack/site build` to compile the site corpus with that pin.
- Run `pnpm --filter @rat-stack/site exec vitest run test/component-registry.test.ts test/reference-components.test.ts` to check the active registry and reader references.
- Run `pnpm test` in the MDFX source repository to check the parser, codemod, source coordinates, and Svelte markup.

This package runs at build time. The existing site generator still owns publication.

## Sources

1. [MDFX v0.3.4 compiler source and tests](https://github.com/joelhooks/mdfx/tree/7de6d12072e29b6a1fa7aa9b6f67aef689344890)
   GitHub joelhooks/mdfx. The grammar, parser, registry, markup emission, and migration contract. Accessed 2026-11-28.

## Linked from

- Agent guide → An Effect stack so pure (aspirational) Kit Langton will blush. → [Read page](https://ratstack.sh/llms.txt)

- Agent rules for rat-stack (AGENTS.md) → What you may change, which commands to run, and which changes need approval. → [Read page](https://ratstack.sh/AGENTS.md)

- Change log → What changed in the files served here, newest first. → [Read page](https://ratstack.sh/log)

- Exact workspace dependency pins (pins.md) → Exact dependency values declared by every workspace package. → [Read page](https://ratstack.sh/pins.md)

- Full agent guide → An Effect stack so pure (aspirational) Kit Langton will blush. → [Read page](https://ratstack.sh/llms-full.txt)

- Rat Stack systems | rat-stack → The systems rat-stack ships, the standard each keeps, and how to check it. → [Read page](https://ratstack.sh/systems)

- Source change history (log.md) → The generated change log as Markdown. → [Read page](https://ratstack.sh/log.md)

- Web → Vite prerenders the reader as HTML that Effect UI hydrates in the browser. → [Read page](https://ratstack.sh/systems/web)

- Wiki cartridge → An in-memory Wiki model validates whole-page batches and serves a replayable public index alongside the static build. → [Read page](https://ratstack.sh/systems/wiki)

- write-a-wiki-page → Write or revise public wiki pages with short prose, cited claims, meaningful visuals, and pinned code snippets. → [Read page](https://ratstack.sh/skills/write-a-wiki-page)
