Skip to content
0 Stars

Catch broken code examples before users do.

Validate code blocks in Markdown and MDX documentation. Go, TypeScript, Rust, Nix, HCL, and Templ. Pure Go, no CGO. CI-friendly.

Get Started →
$ go install github.com/larsartmann/md-go-validator@latest
terminal
# Validate all Go code blocks in your docs
md-go-validator .

# JSON output for CI
md-go-validator -f json -o results.json .

# Multiple languages
md-go-validator -l go,typescript,rust .

Built for documentation that ships.

Every feature designed for real-world CI pipelines and developer workflows.

Multi-Language Validation

Go (built-in parser), TypeScript, TSX, Rust, Nix, HCL/Terraform, and Templ — all embedded, no external tools.

6-Strategy Go Parser

Progressive parsing handles partial snippets: complete files, package wrappers, function bodies, expressions, statements, and imports.

CI-Friendly Output

Table, JSON, YAML, CSV, Markdown, SARIF, and quiet formats. Structured exit codes (0/1/2) for pipeline integration.

Pure Go, No CGO

Uses gotreesitter (pure-Go tree-sitter) for multi-language parsing. Compiles to any GOOS/GOARCH with zero C dependencies.

Baseline Regression Mode

Generate a baseline of known errors, then fail only on new issues. Perfect for incremental adoption in existing projects.

Skip Directives

Mark intentionally incomplete snippets with <!-- skip-validate -->. Custom directives configurable via YAML.

How it works.

Four-step pipeline from markdown to validation report.

1

Extract

Scan Markdown and MDX files for fenced code blocks. Recursive directory traversal with glob excludes.

2

Route

Each block is routed to the correct language validator via the registry. Auto-detected from the info string.

3

Validate

Go blocks pass through 6 progressive parsing strategies. Other languages use embedded tree-sitter parsers.

4

Report

Results in table, JSON, YAML, CSV, Markdown, SARIF, or quiet format. Structured exit codes for CI.

Why md-go-validator?

Purpose-built for documentation validation. Not a generic linter.

markdownlint
Markdown structure linting
Wide ecosystem
Configurable rules
No code block syntax validation
No multi-language parsing
No SARIF output
prettier
Code formatting
Markdown formatting
Wide language support
No syntax validation
Modifies files (not read-only)
Requires Node.js
md-go-validator
Validates code block syntax
6 Go parsing strategies
7 languages via tree-sitter
Pure Go (no CGO)
SARIF + JSON output
Baseline regression mode

Drop it into any workflow.

CI pipelines, pre-commit hooks, GitHub Actions, or your own Go tools.

CI Pipelines

Block PRs that break documentation code examples

Pre-commit Hooks

Catch errors locally before they reach CI

GitHub Actions

Built-in action with zero install needed

Library Integration

Embed validation in your own Go tools

SARIF Reports

Upload results to GitHub Code Scanning

Start validating in seconds.

One install, one command, zero broken docs.