gomarkdown/markdown parses Markdown and renders HTML with CommonMark mode, common extensions, and optional round-trip Markdown output.
Overview
This package is a Go library for parsing Markdown text and producing HTML. It offers a CommonMark mode aligned with the CommonMark 0.31.2 grammar, with tests against the official example suite, alongside a broader extension set for tables, fenced code, autolinks, footnotes, and related syntax.
Parsing builds an abstract syntax tree you can traverse or transform before rendering. The HTML renderer supports flags for untrusted content, such as stripping raw HTML or restricting link schemes. It does not substitute for an HTML sanitizer when serving user-generated content; Bluemonday integration is shown as an example.
A separate mdtohtml command-line tool installs via Go tooling and converts files on disk, illustrating library usage. The renderer can also emit Markdown again from an AST for normalization or reformatting. The implementation emphasizes linear-time parsing, thread-safe concurrent use, and dependence only on the Go standard library.
Key features
- Markdown to HTML conversion
- CommonMark-compliant parser mode
- GFM-style extension set
- AST traversal and transforms
- Markdown round-trip renderer
- Untrusted input renderer flags
- mdtohtml CLI companion
- Thread-safe concurrent parsing
Use cases
- Server-side Markdown rendering in Go
- Static site and blog pipelines
- CommonMark-validated publishing
- Sanitized user comment HTML
- Reformatting Markdown documents