remark-directive

A remark plugin that adds generic directive syntax to markdown, so authors can write custom text, leaf, and container extensions.

Library
npm
v4.0.0
425 stars
MIT License

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum. How we score it →
38 /100 Needs Attention
Development Activity 0
Maintenance 20
Community 44
Maturity 60
Momentum 28

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation. How we score it →
76 /100 Good
Architecture 82
Code Quality 78
Innovation 68
Learning Curve 75

remark-directive is a plugin for the unified/remark ecosystem that implements the CommonMark generic directives proposal — a single, consistent syntax (:name[]{}, ::name[]{}, :::name[]{}) for arbitrary markdown extensions. Rather than inventing a new ad-hoc syntax for every feature (custom containers, embeds, callouts), it gives authors one predictable pattern and gives plugin developers three new mdast node types (textDirective, leafDirective, containerDirective) to visit and transform.

The package itself does no rendering — it only parses directives into the syntax tree and can serialize them back to markdown. Turning a directive into HTML (or anything else) is left to a small user-authored remark plugin that visits the new node types, which keeps remark-directive minimal, dependency-light, and reusable across very different use cases: documentation callouts, video embeds, styled blocks, and more.

What You Get

  • Three new mdast node types — textDirective, leafDirective, containerDirective — added to the parse tree for any markdown containing directive syntax
  • Micromark, fromMarkdown, and toMarkdown extensions wired automatically into the unified processor via a single .use(remarkDirective) call
  • Configurable markdown serialization (collapseEmptyAttributes, preferShortcut, preferUnquoted, quoteSmart, quote) for round-tripping directives back to clean markdown
  • Full TypeScript typings with 100% type coverage, so directive options and node types are statically checked
  • A minimal, unopinionated core — no bundled HTML renderer, so it composes with any downstream rendering plugin

Common Use Cases

  • Documentation sites using :::note{.warning} style container directives for callouts and admonitions
  • Static site generators embedding rich media (e.g. ::youtube[]{v=...}) via leaf directives instead of raw HTML
  • CMS or blogging platforms offering non-technical authors a constrained, safe extension syntax instead of full HTML/JSX
  • Plugin authors building higher-level markdown extensions (custom components, styled blocks) on top of the directive node types

Under The Hood

Architecture The entire runtime is a single default-export function (lib/index.js, under 40 lines) that runs once when a unified processor attaches the plugin: it reads this.data(), lazily initializes the processor’s micromarkExtensions, fromMarkdownExtensions, and toMarkdownExtensions arrays, and pushes one extension of each kind sourced from micromark-extension-directive (tokenizing) and mdast-util-directive (tree construction/serialization). There is no additional module graph, no internal state beyond what unified already manages, and no rendering logic at all — directive-to-HTML conversion is explicitly deferred to a separate plugin the consumer writes, which keeps the core’s blast radius trivial if the directive spec or unified’s plugin API changes.

Tech Stack Built as a pure ESM Node.js package ("type": "module", Node 16+ engines) with zero bundler or framework dependencies. Its four runtime dependencies are all part of the unified/remark/micromark ecosystem: @types/mdast for tree typings, mdast-util-directive for AST construction and markdown stringification, micromark-extension-directive for tokenizing the directive syntax, and unified itself. TypeScript types are hand-authored in index.d.ts (not compiled from .ts sources) and checked via tsc --build plus type-coverage in the build script.

Code Quality Tests live in test/index.js using Node’s built-in node:test and assert/strict, combined with a fixture-driven harness that walks test/fixtures/{container,leaf,text} directories, parses each input.md, and diffs both the resulting mdast tree (tree.json) and the re-serialized markdown output against checked-in expectations — a solid regression net for syntax-tree correctness even though it’s a small surface area. The project enforces 100% branch coverage via c8 --100 and lints with xo plus remark-preset-wooorm (dogfooding its own ecosystem’s linting conventions) and Prettier, all wired into a single npm test script alongside the type-coverage build step.

What Makes It Unique Unlike ad-hoc “one syntax per feature” extensions, remark-directive implements a single community-proposed generic directive grammar shared across the unified ecosystem, which lets independent plugin authors standardize on one attribute/naming convention instead of each inventing incompatible container syntaxes. Its deliberate refusal to bundle a renderer is itself the notable design choice: by staying a pure syntax-to-tree layer, it stays composable with arbitrarily different output targets (HTML via hast, or entirely custom renderers) without ever needing to know about them.

Used by 8 apps in this directory

Python
55%
Other

authentik

Authentication · Security

25,758

The self-hosted Identity Provider that replaces Okta, Auth0, and Entra ID with a unified SSO platform supporting SAML, OAuth2/OIDC, LDAP, RADIUS, and WebAuthn.

View details
92
Repo Health
81
Technical
66
Dependency
Built with
Python 55%
TypeScript 36%
Updated 4 days ago
Rust
52%
Apache 2.0

cocoindex

AI Development · Data Engineering

11,607

An incremental data indexing engine that keeps AI agent context perpetually fresh by reprocessing only what changed.

View details
87
Repo Health
85
Technical
65
Dependency
Built with
Rust 52%
Python 48%
Updated 4 days ago
TypeScript
50%
Other

Dify

AI Development · Design Tools · Developer Tools

157,364

Visual LLM workflow platform with RAG pipelines, agent capabilities, and model management for building production AI applications.

View details
92
Repo Health
85
Technical
66
Dependency
Built with
TypeScript 50%
Python 47%
Updated 4 days ago
Java
58%
Apache 2.0

Kestra

Automation · Data Engineering · Devops

28,388

Event-driven orchestration platform for data, AI, and infrastructure workflows — define everything in YAML, run anywhere at scale.

View details
93
Repo Health
81
Technical
72
Dependency
Built with
Java 58%
TypeScript 26%
Vue 15%
Updated 1 weeks ago
Rust
47%
MIT

Kuku

Note Taking

225

A local-first, open-source Markdown knowledge workspace for macOS — plain files, personal wiki and Second Brain workflows, AI-assisted diffs, and encrypted sync, built as an Obsidian alternative.

View details
52
Repo Health
67
Technical
67
Dependency
Built with
Rust 47%
TypeScript 40%
Updated 3 weeks ago
TypeScript
82%
MIT

LibreChat

AI Assistants · Developer Tools

45,009

Unite every major AI model in one self-hosted chat platform with agents, code execution, MCP tools, and enterprise authentication.

View details
93
Repo Health
81
Technical
65
Dependency
Built with
TypeScript 82%
JavaScript 17%
Updated 4 days ago
TypeScript
88%
MIT

medusa

Ecommerce

36,494

The most flexible open-source commerce platform — build B2C, B2B, and marketplace applications with modular, composable commerce primitives.

View details
93
Repo Health
87
Technical
63
Dependency
Built with
TypeScript 88%
JavaScript 12%
Updated 1 weeks ago
Rust
77%
Apache 2.0

SlateDB

Databases · Developer Tools

3,448

Embedded KV store built on object storage with zero replication cost

View details
87
Repo Health
73
Technical
72
Dependency
Built with
Rust 77%
Updated 1 weeks ago

Join founders buildingwith open source

Opinionated takes, migration guides, cost-saving tips, and insights from the open source ecosystem.

Subscribe on Substack
Join 750+ subscribers