DEV Community

Arthur031221
Arthur031221

Posted on

Check Markdown examples before someone copies them

snipverify checks a broken README, then shows the clean result after repair

A project can have a green test suite while its README example is stale. The docs are often the first thing a new user runs, and one missing colon or moved setup link can waste the first few minutes.

I built snipverify to check syntax in fenced code blocks and local targets in relative links. It scans Markdown files from a directory or one file at a time. The first release checks JavaScript, TypeScript, Python, JSON, Bash, and POSIX shell examples.

What it checks

For each supported code fence, snipverify parses the contents and reports the file and source line when the syntax is invalid. It does not start the commands or scripts from the document. For local links and images, it checks whether the relative target exists on disk. It skips external URLs and fragment-only links.

Unlabeled fences and languages without a checker are reported as skipped. This makes an unsupported block visible without treating it as a syntax error. A JSON mode is available for CI, so a job can preserve file, line, status, and message for each finding.

Try it

From the repository root, run:

npx --yes --package=github:Arthur031221/snipverify snipverify examples/fixed/README.md
Enter fullscreen mode Exit fullscreen mode

The repository also contains a deliberately broken Markdown fixture. It has a Python syntax error and a relative link to a missing file, which lets you see the report before fixing both problems.

What is rough

This is a static check, not an example runner. A passing result does not show that a command has the right output, that its dependencies are installed, or that an external website is reachable. The supported fence labels and Markdown link forms are also a small subset of the formats people use in documentation.

I would like feedback on valid examples that are rejected, link forms worth adding, and languages maintainers want checked. The source and issue tracker are here: https://github.com/Arthur031221/snipverify.

Top comments (0)