cmark
Render Markdown to HTML or other formats
TLDR
Render a CommonMark Markdown file to HTML
Convert data from stdin to LaTeX
Convert straight quotes to smart quotes
Validate UTF-8 characters
SYNOPSIS
cmark [OPTION]... [FILE]
PARAMETERS
-h, --help
Print a short usage message and exit.
-V, --version
Print program version information and exit.
-o, --output FILE
Specify output file (default: stdout).
-t, --to FORMAT
Output format: html (default), latex, man, commonmark, xml.
-f, --from FORMAT
Input format: markdown (default), commonmark, gfm, commonmark_extensions.
-s, --standalone
Generate a standalone document with header/footer (HTML, LaTeX, man).
--table-attributes
Put style attributes on tables generated from Markdown table syntax.
--fenced-code-attributes
Generate attributes on fenced code blocks from info strings.
--validate-utf8
Validate UTF-8 in input (treat invalid sequences as errors).
--smart
Enable smart quotes, apostrophes, and ellipses.
--sourcepos
Include source position attributes in output.
--unsafe
Allow raw HTML and dangerous script tags (not recommended).
--ascii
Use ASCII-only characters in generated output.
DESCRIPTION
cmark is the official reference implementation of the CommonMark Markdown specification, written in C. It parses Markdown files and renders them to HTML, LaTeX, man pages, XML, or CommonMark. Designed for speed and standards compliance, it supports the full CommonMark spec plus optional extensions like tables, fenced code attributes, and GitHub Flavored Markdown (GFM) elements.
Key features include strict parsing to ensure consistent output across implementations, UTF-8 validation, smart punctuation (curly quotes), and safe HTML generation by default (no script execution). It's lightweight, with no external dependencies beyond libc, making it ideal for embedded systems or scripts. Input can come from files or stdin, with output to files or stdout.
Unlike full-featured tools like Pandoc, cmark focuses on core Markdown without advanced features like bibliographies or custom writers, prioritizing portability and performance. It's widely used in static site generators, documentation tools, and as a test suite for other parsers.
CAVEATS
Strictly adheres to CommonMark spec; lacks support for many vendor extensions (e.g., footnotes) unless using GFM mode. HTML output is safe by default but can be made unsafe with --unsafe. No built-in syntax highlighting.
DEFAULT BEHAVIOR
Reads from stdin if no FILE given; outputs HTML to stdout.
EXTENSIONS
Supports autolink, strikethrough, tables, tasklists via --from commonmark_extensions or GFM.
HISTORY
Developed by John MacFarlane as the reference implementation for the CommonMark 0.27 spec in 2014. Actively maintained with releases tracking spec updates; version 0.30+ adds GFM and extension support. Widely adopted for its reliability and speed.


