Agent skill
commonmark
Use when parsing or generating Markdown following the CommonMark specification - AST structure, block/inline elements, and extensions
Install this agent skill to your Project
npx add-skill https://github.com/majiayu000/claude-skill-registry/tree/main/skills/data/commonmark
SKILL.md
CommonMark Markdown
Quick Start
import { Parser, HtmlRenderer } from 'commonmark';
const parser = new Parser();
const renderer = new HtmlRenderer();
const ast = parser.parse('# Hello\n\nWorld');
const html = renderer.render(ast);
AST Node Types
Block Elements
| Type | Description |
|---|---|
document |
Root node |
heading |
# through ###### |
paragraph |
Text block |
code_block |
Fenced (```) or indented |
block_quote |
> prefixed |
list |
Ordered or bullet list |
item |
List item |
thematic_break |
---, ***, ___ |
Inline Elements
| Type | Description |
|---|---|
text |
Plain text |
emph |
*italic* or _italic_ |
strong |
**bold** or __bold__ |
code |
`inline` |
link |
[text](url) |
image |
 |
softbreak |
Line break in source |
hardbreak |
Two spaces + newline |
Walking the AST
const walker = ast.walker();
let event;
while ((event = walker.next())) {
const { node, entering } = event;
if (node.type === 'heading' && entering) {
console.log(`H${node.level}: ${node.firstChild?.literal}`);
}
}
Key Parsing Rules
- Blank line separates paragraphs
- 4-space indent = code block (unless in list)
- Fenced code: 3+ backticks, optional info string
- Setext headings:
===or---underline - Links:
[text](url "title")or[text][ref]
Extensions (GFM)
GitHub Flavored Markdown adds:
- Tables:
| col | col | - Strikethrough:
~~text~~ - Task lists:
- [ ]and- [x] - Autolinks: URLs become links automatically
Tips
- Use
node.literalfor text content - Use
node.destinationfor link/image URLs node.infocontains fenced code language- Modify AST before rendering for transformations
Recommended Agent Skills
Expand your agent's capabilities with these related and highly-rated skills.
agent-ops-spec
Manage specification documents in .agent/specs/. Use when user provides requirements, acceptance criteria, or feature descriptions that need to be tracked and validated against implementation.
agent-ops-state
Maintain .agent state files. Use at session start, after meaningful steps, and before concluding: read/update constitution/memory/focus/issues/baseline consistently.
agent-ops-spec
Manage specification documents in .agent/specs/. Use when user provides requirements, acceptance criteria, or feature descriptions that need to be tracked and validated against implementation.
agent-ops-testing
Test strategy, execution, and coverage analysis. Use when designing tests, running test suites, or analyzing test results beyond baseline checks.
agent-ops-testing
Test strategy, execution, and coverage analysis. Use when designing tests, running test suites, or analyzing test results beyond baseline checks.
agent-ops-state
Maintain .agent state files. Use at session start, after meaningful steps, and before concluding: read/update constitution/memory/focus/issues/baseline consistently.
Didn't find tool you were looking for?