Claude-skill-registry commonmark
Use when parsing or generating Markdown following the CommonMark specification - AST structure, block/inline elements, and extensions
install
source · Clone the upstream repo
git clone https://github.com/majiayu000/claude-skill-registry
Claude Code · Install into ~/.claude/skills/
T=$(mktemp -d) && git clone --depth=1 https://github.com/majiayu000/claude-skill-registry "$T" && mkdir -p ~/.claude/skills && cp -r "$T/skills/data/commonmark" ~/.claude/skills/majiayu000-claude-skill-registry-commonmark && rm -rf "$T"
manifest:
skills/data/commonmark/SKILL.mdsource content
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 |
|---|---|
| Root node |
| through |
| Text block |
| Fenced (```) or indented |
| prefixed |
| Ordered or bullet list |
| List item |
| , , |
Inline Elements
| Type | Description |
|---|---|
| Plain text |
| or |
| or |
| |
| |
| |
| Line break in source |
| 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:
or[text](url "title")[text][ref]
Extensions (GFM)
GitHub Flavored Markdown adds:
- Tables:
| col | col | - Strikethrough:
~~text~~ - Task lists:
and- [ ]- [x] - Autolinks: URLs become links automatically
Tips
- Use
for text contentnode.literal - Use
for link/image URLsnode.destination
contains fenced code languagenode.info- Modify AST before rendering for transformations