agentic-markdown
v0.0.4
Published
Render variable-aware Markdown from conditional comment blocks.
Maintainers
Readme
agentic-markdown
Render variable-aware Markdown from conditional HTML comment blocks.
Install
npm add agentic-markdownUsage
import { render } from "agentic-markdown";
const markdown = `Common content.
Project: <!-- agentic:var projectName -->
<!-- agentic:if agent=codex -->
Codex-only content.
<!-- agentic:endif -->
<!-- agentic:if agent=claude|gemini -->
Claude and Gemini content.
<!-- agentic:endif -->
`;
const output = render(markdown, {
agent: "codex",
projectName: "agentic-markdown",
});output:
Common content.
Project: agentic-markdown
Codex-only content.Syntax
Use HTML comments to mark variable-specific Markdown spans:
<!-- agentic:if agent=codex -->
Codex-only content.
<!-- agentic:endif -->They may also appear inline:
Use <!-- agentic:if agent=codex -->Codex<!-- agentic:endif --> instructions.The agentic:if value is either a variable=value condition or a presence/non-empty check. Use | to match any of
multiple values. Matching is case-sensitive.
render(markdown, { agent: "codex" });A variable=value block is kept when the configured variable matches one of the expected values. Missing variables are
treated as non-matches instead of errors.
Omit = to keep a block when the configured variable has a non-empty value. Missing or empty variables are also treated
as non-matches:
<!-- agentic:if projectName -->
Project-specific content.
<!-- agentic:endif -->Use agentic:var comments to replace variables. They may appear inline or on their own line:
Project: <!-- agentic:var projectName -->render(markdown, {
projectName: "agentic-markdown",
});agentic:var requires the variable to be configured. Missing variables throw an error.
When condition comments are on their own line, the whole directive line is removed. Inline condition comments only remove the comment itself, or the excluded span when the agent does not match. Nested condition blocks are not supported in this first version; malformed blocks throw an error.
