cmark

CommonMark Markdown parser and renderer

TLDR

Convert Markdown to HTML
$ cmark [input.md]
Convert to specific format
$ cmark --to [html|xml|man|latex] [input.md]
Read from stdin
$ cat [input.md] | cmark
Output to file
$ cmark [input.md] > [output.html]
Enable smart typography
$ cmark --smart [input.md]
Convert to groff man page format
$ cmark --to man [input.md]
Validate UTF-8 and replace invalid sequences
$ cmark --validate-utf8 [input.md]
Render with hard line breaks
$ cmark --hardbreaks [input.md]

SYNOPSIS

cmark [options] [file...]

DESCRIPTION

cmark is the reference C implementation of CommonMark, a strongly specified and highly compatible variant of Markdown. It parses Markdown input and converts it to various output formats including HTML, XML, groff man pages, CommonMark, and LaTeX.The parser is designed for correctness and performance, strictly following the CommonMark specification to eliminate the ambiguities present in the original Markdown description. This makes it suitable for applications that require predictable, consistent rendering across different tools.cmark reads from files or standard input and writes to standard output, making it easy to integrate into pipelines. The --smart option provides typographic enhancements like curly quotes and em-dashes, while --safe strips potentially dangerous raw HTML from input.

PARAMETERS

--to format

Output format: html, xml, man, commonmark, latex.
--smart
Enable smart punctuation (curly quotes, dashes).
--safe
Omit raw HTML and potentially unsafe links.
--validate-utf8
Validate UTF-8 and replace invalid sequences.
--hardbreaks
Render soft breaks as hard breaks.
--nobreaks
Render soft breaks as spaces.
--width N
Wrap text at N columns (default 0, no wrap). Only affects commonmark and man output.
--sourcepos
Include source position information in output.

INSTALL

sudo apt install cmark
sudo dnf install cmark
sudo pacman -S cmark
sudo apk add cmark
sudo zypper install cmark
brew install cmark
nix profile install nixpkgs#cmark

HISTORY

cmark is the reference C implementation of the CommonMark specification, developed by John MacFarlane and contributors starting in 2014. CommonMark was created to provide a formal, unambiguous specification for Markdown.

SEE ALSO

pandoc(1), markdown(1), grip(1)