commonmark/cmark
FreeCommonMark parsing and rendering library and program in C
About commonmark/cmark
cmark is the C reference implementation of CommonMark, a standardized version of Markdown syntax. It provides a shared library (libcmark) for parsing CommonMark documents into an abstract syntax tree (AST), manipulating the AST, and rendering to HTML, groff man, LaTeX, CommonMark, or XML. It also includes a command-line program (cmark). The library is written in standard C99 with no external dependencies, making it highly portable. cmark is extremely fast, passing all CommonMark conformance tests, and has been extensively fuzz-tested for robustness. It supports multiple renderers and is BSD2-licensed. Wrappers exist for Python, Lua, Ruby, and other languages, with additional libraries for Go, Haskell, Ruby, and more.
Key Features
Pros & Cons
- Extremely fast performance (comparable to fastest Markdown processors)
- High accuracy (passes all CommonMark conformance tests)
- Portable across platforms and compilers (MSVC, gcc, tcc, clang)
- Robust and well-tested (fuzzing and pathological cases)
- Flexible AST manipulation enables custom processing
- Multiple output formats built-in (HTML, man, LaTeX, CommonMark, XML)
- BSD2 license allows unrestricted use and modification
- Only supports CommonMark specification, not other Markdown flavors
- C library may be less accessible for web developers compared to JavaScript alternatives
- Requires C knowledge for extending or building custom renderers
- Command-line tool lacks some user-friendly features of higher-level tools