# [Comrak](https://comrak.ee/)
[](https://github.com/kivikakk/comrak/actions/workflows/rust.yml)
[](https://github.com/commonmark/commonmark-spec/blob/9103e341a973013013bb1a80e13567007c5cef6f/spec.txt)
[](https://github.com/kivikakk/cmark-gfm/blob/2f13eeedfe9906c72a1843b03552550af7bee29a/test/spec.txt)
[](https://crates.io/crates/comrak)
[](https://docs.rs/comrak)
[](https://www.bestpractices.dev/projects/11796)
[Comrak](https://comrak.ee/) is a [CommonMark](https://commonmark.org/) and [GitHub Flavored Markdown](https://github.github.com/gfm/) compatible parser and renderer, written in Rust.
Compliant with [CommonMark 0.31.2](https://spec.commonmark.org/0.31.2/) by default.
## Installation
Specify it as a requirement in `Cargo.toml`:
```toml
[dependencies]
comrak = "0.54"
```
Comrak's library supports Rust 1.85+.
### CLI
- Anywhere with a Rust toolchain:
- `cargo install comrak`
- [cargo binstall](https://github.com/cargo-bins/cargo-binstall) comrak
- Many Unix distributions:
- `pacman -S comrak`
- `brew install comrak`
- `dnf install comrak`
- `nix run nixpkgs#comrak`
- Windows:
- [scoop](https://scoop.sh/) install comrak
You can also find builds I've published in [GitHub Releases](https://github.com/kivikakk/comrak/releases), but they're limited to machines I have access to at the time of making them! [webinstall.dev](https://webinstall.dev/comrak/) offers `curl | shell`-style installation of the latest of these for your OS, including Windows.
## Usage
Click to expand the CLI --help output.
```console
$ comrak --help
```
```
A 100% CommonMark-compatible GitHub Flavored Markdown parser and formatter
Usage: comrak [OPTIONS] [FILE]...
Arguments:
[FILE]...
CommonMark file(s) to parse; or standard input if none passed
Options:
-c, --config-file
Path to config file containing command-line arguments, or 'none'
[default: /home/runner/.config/comrak/config]
-i, --inplace
Reformat CommonMark files in-place
--hardbreaks
Treat newlines as hard line breaks
--smart
Replace punctuation like "this" with smart punctuation like “this”
--github-pre-lang
Use GitHub-style "
" for code blocks
--full-info-string
Include words following the code block info string in a data-meta attribute
--gfm
Enable GitHub-flavored markdown extensions: strikethrough, tagfilter, table, autolink, and
tasklist. Also enables --github-pre-lang and --gfm-quirks
--gfm-quirks
Use GFM-style quirks in output HTML, such as not nesting tags, which otherwise
breaks CommonMark compatibility
--relaxed-tasklist-character
Permit any character inside a tasklist item, not just " ", "x" or "X"
--relaxed-autolinks
Relax autolink parsing: allows links to be recognised when in brackets, permits all URL
schemes, and permits domains without a TLD (like "http://localhost")
--tasklist-classes
Include "task-list-item" and "task-list-item-checkbox" classes on
--default-info-string
Default value for fenced code block's info strings if none is given
--unsafe
Allow inline and block HTML (unless --escape is given), and permit
--gemoji
Translate gemoji like ":thumbsup:" into Unicode emoji like "👍"
--escape
Escape raw HTML, instead of clobbering it; takes precedence over --unsafe
--escaped-char-spans
Wrap escaped Markdown characters in "" in HTML
-e, --extension
Specify extensions to use
Multiple extensions can be delimited with ",", e.g. '--extension strikethrough,table', or
you can pass --extension/-e multiple times
[possible values: strikethrough, tagfilter, table, autolink, tasklist, superscript,
footnotes, inline-footnotes, description-lists, multiline-block-quotes, math-dollars,
math-latex, math-code, wikilinks-title-after-pipe, wikilinks-title-before-pipe, underline,
subscript, spoiler, greentext, alerts, cjk-friendly-emphasis, subtext, highlight, insert,
phoenix-heex, block-directive, header-attributes, fenced-code-attributes,
inline-code-attributes, link-attributes]
-t, --to
Specify output format
[default: html]
[possible values: html, xml, commonmark]
-o, --output
Write output to FILE instead of stdout
--width
Specify wrap width for output CommonMark, or '0' to disable wrapping
[default: 0]
--header-id-prefix
Use the Comrak header IDs extension, with the given ID prefix
--header-id-prefix-in-href
Apply the header ID prefix to the href anchor as well
--front-matter-delimiter
Detect frontmatter that starts and ends with the given string, and do not include it in
the resulting document
--syntax-highlighting
Syntax highlighting for fenced code blocks; 'css' for CSS classes (default), a theme name
for inline styles, or 'none' to disable
[default: css]
--list-style
Specify bullet character for lists ("-", "+", "*") in CommonMark output
[default: dash]
[possible values: dash, plus, star]
--alert-style
Specify alert style (