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
420stars
MIT License

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum.How we score it →
38/100Needs Attention
Development Activity0
Maintenance20
Community44
Maturity60
Momentum28

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation.How we score it →
76/100Good
Architecture82
Code Quality78
Innovation68
Learning Curve75

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
56%
Other

authentik

Authentication · Security

25,385

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
Python56%
TypeScript34%
Updated yesterday
Rust
52%
Apache 2.0

cocoindex

Data Engineering · AI Development

11,496

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

View details
86
Repo Health
85
Technical
64
Dependency
Built with
Rust52%
Python48%
Updated 2 days ago
TypeScript
50%
Other

Dify

No Code Platforms · AI Development · Developer Tools

154,649

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

View details
92
Repo Health
85
Technical
67
Dependency
Built with
TypeScript50%
Python46%
Updated yesterday
Java
59%
Apache 2.0

Kestra

Devops · Data Engineering · Automation

28,007

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

View details
94
Repo Health
81
Technical
72
Dependency
Built with
Java59%
TypeScript25%
Vue15%
Updated yesterday
Rust
47%
MIT

Kuku

Note Taking

219

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
81
Repo Health
67
Technical
67
Dependency
Built with
Rust47%
TypeScript40%
Updated yesterday
TypeScript
81%
MIT

LibreChat

Developer Tools · AI Assistants

42,871

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
TypeScript81%
JavaScript18%
Updated today
TypeScript
86%
MIT

medusa

Ecommerce

36,163

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
TypeScript86%
JavaScript14%
Updated 2 days ago
Rust
77%
Apache 2.0

SlateDB

Databases · Developer Tools

3,388

Embedded KV store built on object storage with zero replication cost

View details
88
Repo Health
73
Technical
76
Dependency
Built with
Rust77%
Updated yesterday

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

Search