Skip to content
Back to skills

Commonmark

ASecurity

Use when parsing or generating Markdown following the CommonMark specification - AST structure, block/inline elements, and extensions

  • 666 stars
  • 0 votes
  • 0 copies
  • 7 views
  • Added February 8, 2026
documentationtypescriptnodegit

Security analysis

A100/100

Scanned February 12, 2026

npx -y skills add majiayu000/claude-skill-registry --skill commonmark --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Commonmark?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Commonmark
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/majiayu000-commonmark/badge)](https://www.skillsdirectory.com/skills/majiayu000-commonmark)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: commonmark
# prettier-ignore
description: Use when parsing or generating Markdown following the CommonMark specification - AST structure, block/inline elements, and extensions
---

# CommonMark Markdown

## Quick Start

```typescript
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` | `![alt](src)` |
| `softbreak` | Line break in source |
| `hardbreak` | Two spaces + newline |

## Walking the AST

```typescript
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.literal` for text content
- Use `node.destination` for link/image URLs
- `node.info` contains fenced code language
- Modify AST before rendering for transformations

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.