@@ -8,19 +8,19 @@ Collective](https://opencollective.com/comrak/all/badge.svg?label=financial+cont
88
99Rust port of [ github's ` cmark-gfm ` ] ( https://github.com/github/cmark ) .
1010
11- - [ Installation] ( #installation )
12- - [ Usage] ( #usage )
13- - [ Security] ( #security )
14- - [ Extensions] ( #extensions )
15- - [ Related projects] ( #related-projects )
16- - [ Contributing] ( #contributing )
17- - [ Legal] ( #legal )
11+ - [ Installation] ( #installation )
12+ - [ Usage] ( #usage )
13+ - [ Security] ( #security )
14+ - [ Extensions] ( #extensions )
15+ - [ Related projects] ( #related-projects )
16+ - [ Contributing] ( #contributing )
17+ - [ Legal] ( #legal )
1818
1919## Installation
2020
2121Specify it as a requirement in ` Cargo.toml ` :
2222
23- ``` toml
23+ ``` toml
2424[dependencies ]
2525comrak = " 0.15"
2626```
@@ -29,19 +29,19 @@ Comrak supports Rust stable.
2929
3030### Mac & Linux Binaries
3131
32- ``` bash
32+ ``` bash
3333curl https://webinstall.dev/comrak | bash
3434```
3535
3636### Windows 10 Binaries
3737
38- ``` powershell
38+ ``` powershell
3939curl.exe -A "MS" https://webinstall.dev/comrak | powershell
4040```
4141
4242## Usage
4343
44- ``` console
44+ ``` console
4545$ comrak --help
4646A 100% CommonMark-compatible GitHub Flavored Markdown parser and formatter
4747
@@ -54,7 +54,7 @@ Arguments:
5454Options:
5555 -c, --config-file <PATH>
5656 Path to config file containing command-line arguments, or 'none'
57-
57+
5858 [default: /Users/kivikakk/.config/comrak/config]
5959
6060 --hardbreaks
@@ -76,20 +76,23 @@ Options:
7676 --unsafe
7777 Allow raw HTML and dangerous URLs
7878
79+ --gemojis
80+ Translate gemojis into UTF-8 characters
81+
7982 --escape
8083 Escape raw HTML instead of clobbering it
8184
8285 -e, --extension <EXTENSION>
8386 Specify extension name(s) to use
84-
87+
8588 Multiple extensions can be delimited with ",", e.g. --extension strikethrough,table
86-
89+
8790 [possible values: strikethrough, tagfilter, table, autolink, tasklist, superscript,
8891 footnotes, description-lists]
8992
9093 -t, --to <FORMAT>
9194 Specify output format
92-
95+
9396 [default: html]
9497 [possible values: html, commonmark]
9598
@@ -98,7 +101,7 @@ Options:
98101
99102 --width <WIDTH>
100103 Specify wrap width (0 = nowrap)
101-
104+
102105 [default: 0]
103106
104107 --header-ids <PREFIX>
@@ -109,12 +112,12 @@ Options:
109112
110113 --syntax-highlighting <THEME>
111114 Syntax highlighting for codefence blocks. Choose a theme or 'none' for disabling
112-
115+
113116 [default: base16-ocean.dark]
114117
115118 --list-style <LIST_STYLE>
116119 Specify bullet character for lists (-, +, *) in CommonMark ouput
117-
120+
118121 [default: dash]
119122 [possible values: dash, plus, star]
120123
@@ -131,15 +134,15 @@ the file does not exist.
131134
132135And there's a Rust interface. You can use ` comrak::markdown_to_html ` directly:
133136
134- ``` rust
137+ ``` rust
135138use comrak :: {markdown_to_html, ComrakOptions };
136139assert_eq! (markdown_to_html (" Hello, **世界**!" , & ComrakOptions :: default ()),
137140 " <p>Hello, <strong>世界</strong>!</p>\ n" );
138141```
139142
140143Or you can parse the input into an AST yourself, manipulate it, and then use your desired formatter:
141144
142- ``` rust
145+ ``` rust
143146extern crate comrak;
144147use comrak :: {parse_document, format_html, Arena , ComrakOptions };
145148use comrak :: nodes :: {AstNode , NodeValue };
@@ -196,19 +199,20 @@ use of a sanitisation library like [`ammonia`](https://github.com/notriddle/ammo
196199Comrak supports the five extensions to CommonMark defined in the [ GitHub Flavored Markdown
197200Spec] ( https://github.github.com/gfm/ ) :
198201
199- - [ Tables] ( https://github.github.com/gfm/#tables-extension- )
200- - [ Task list items] ( https://github.github.com/gfm/#task-list-items-extension- )
201- - [ Strikethrough] ( https://github.github.com/gfm/#strikethrough-extension- )
202- - [ Autolinks] ( https://github.github.com/gfm/#autolinks-extension- )
203- - [ Disallowed Raw HTML] ( https://github.github.com/gfm/#disallowed-raw-html-extension- )
202+ - [ Tables] ( https://github.github.com/gfm/#tables-extension- )
203+ - [ Task list items] ( https://github.github.com/gfm/#task-list-items-extension- )
204+ - [ Strikethrough] ( https://github.github.com/gfm/#strikethrough-extension- )
205+ - [ Autolinks] ( https://github.github.com/gfm/#autolinks-extension- )
206+ - [ Disallowed Raw HTML] ( https://github.github.com/gfm/#disallowed-raw-html-extension- )
204207
205208Comrak additionally supports its own extensions, which are yet to be specced out (PRs welcome\! ):
206209
207- - Superscript
208- - Header IDs
209- - Footnotes
210- - Description lists
211- - Front matter
210+ - Superscript
211+ - Header IDs
212+ - Footnotes
213+ - Description lists
214+ - Front matter
215+ - Shortcodes
212216
213217By default none are enabled; they are individually enabled with each parse by setting the appropriate values in the
214218[ ` ComrakOptions ` struct] ( https://docs.rs/comrak/newest/comrak/struct.ComrakOptions.html ) .
@@ -238,17 +242,17 @@ in terms of code structure. The upside of this is that a change in `cmark-gfm` h
238242Likewise, any bug in ` cmark-gfm ` is likely to be reproduced in Comrak. This could be considered a pro or a con,
239243depending on your use case.
240244
241- The downside, of course, is that the code is not what I'd call idiomatic Rust (* so many ` RefCell ` s * ), and while
245+ The downside, of course, is that the code is not what I'd call idiomatic Rust (_ so many ` RefCell ` s _ ), and while
242246contributors and I have made it as fast as possible, it simply won't be as fast as some other CommonMark parsers
243247depending on your use-case. Here are some other projects to consider:
244248
245- - [ Raph Levien] ( https://github.com/raphlinus ) 's [ ` pulldown-cmark ` ] ( https://github.com/google/pulldown-cmark ) . It's
246- very fast, uses a novel parsing algorithm, and doesn't construct an AST (but you can use it to make one if you
247- want). ` cargo doc ` uses this, as do many other projects in the ecosystem.
248- - [ Ben Navetta] ( https://github.com/bnavetta ) 's [ ` rcmark ` ] ( https://github.com/bnavetta/rcmark ) is a set of bindings to
249- ` libcmark ` . It hasn't been updated in a while, though there's an [ open pull
250- request] ( https://github.com/bnavetta/rcmark/pull/2 ) .
251- - Know of another library? Please open a PR to add it\!
249+ - [ Raph Levien] ( https://github.com/raphlinus ) 's [ ` pulldown-cmark ` ] ( https://github.com/google/pulldown-cmark ) . It's
250+ very fast, uses a novel parsing algorithm, and doesn't construct an AST (but you can use it to make one if you
251+ want). ` cargo doc ` uses this, as do many other projects in the ecosystem.
252+ - [ Ben Navetta] ( https://github.com/bnavetta ) 's [ ` rcmark ` ] ( https://github.com/bnavetta/rcmark ) is a set of bindings to
253+ ` libcmark ` . It hasn't been updated in a while, though there's an [ open pull
254+ request] ( https://github.com/bnavetta/rcmark/pull/2 ) .
255+ - Know of another library? Please open a PR to add it\!
252256
253257As far as I know, Comrak is the only library to implement all of the [ GitHub Flavored Markdown
254258extensions] ( https://github.github.com/gfm ) to the spec, but this tends to only be important if you want to reproduce
0 commit comments