<commit_before># Cmark

[![Hex.pm package version](https://img.shields.io/hexpm/v/cmark.svg?style=flat-square)](https://hex.pm/packages/cmark)
[![Hex.pm package docs](https://img.shields.io/badge/hex-docs-orange.svg?style=flat-square)](http://hexdocs.pm/cmark/)
[![Hex.pm package license](https://img.shields.io/hexpm/l/cmark.svg?style=flat-square)](https://github.com/asaaki/cmark.ex/blob/master/LICENSE)
[![Build Status (master)](https://img.shields.io/travis/asaaki/cmark.ex/master.svg?style=flat-square)](https://travis-ci.org/asaaki/cmark.ex)
[![Coverage Status (master)](https://img.shields.io/coveralls/asaaki/cmark.ex/master.svg?style=flat-square)](https://coveralls.io/r/asaaki/cmark.ex)
[![Inline docs](http://inch-ci.org/github/asaaki/cmark.ex.svg?branch=master&style=flat-square)](http://inch-ci.org/github/asaaki/cmark.ex)

Elixir NIF for [cmark (C)](https://github.com/jgm/cmark), a parser library following the [CommonMark](http://commonmark.org/) spec.

## CommonMark

> A strongly specified, highly compatible implementation of Markdown

For more information visit <http://commonmark.org/>.

## Install

### Prerequisites

You need a C compiler like `gcc` or `clang`.

### mix.exs

Add this to your dependencies:

```elixir
{:cmark, "~> 0.6"}
```

## Usage

### Quick example

```elixir
Cmark.to_html "a markdown string"
#=> "<p>a markdown string</p>\n"
```

### Cmark.to_html/1

```elixir
"test" |> Cmark.to_html
#=> "<p>test</p>\n"
```

```elixir
["# also works", "* with list", "`of documents`"] |> Cmark.to_html
#=> ["<h1>also works</h1>\n",
#    "<ul>\n<li>with list</li>\n</ul>\n",
#    "<p><code>of documents</code></p>\n"]
```

### Cmark.to_html/2

```elixir
callback = fn (html) -> "HTML is #{html}" |> String.strip end
"test" |> Cmark.to_html(callback)
#=> "HTML is <p>test</p>"
```

```elixir
callback = fn (htmls) ->
 Enum.map(htmls, &String.strip/1) |> Enum.join("<hr>")
end
["list", "test"] |> Cmark.to_html(callback)
#=> "<p>list</p><hr><p>test</p>"
```

### Cmark.to_html_each/2

```elixir
callback = fn (html) -> "HTML is #{html |> String.strip}" end
["list", "test"] |> Cmark.to_html_each(callback)
#=> ["HTML is <p>list</p>", "HTML is <p>test</p>"]
```

### Other output formats

Thanks to the [cmark project](https://github.com/jgm/cmark) this library also supports further output formats:

- XML: `Cmark.to_xml/1,2,3`, `Cmark.to_xml_each/2`
- Manpage: `Cmark.to_man/1,2,3`, `Cmark.to_man_each/2`
- CommonMark: `Cmark.to_commonmark/1,2,3`, `Cmark.to_commonmark_each/2`
- LaTeX: `Cmark.to_latex/1,2,3`, `Cmark.to_latex_each/2`

## Documentation

Latest API docs can be found at: <http://hexdocs.pm/cmark/0.6.2/Cmark.html>

## Licenses

- Cmark.ex: [LICENSE](./LICENSE) (MIT)
- cmark (C): [c_src/COPYING](./c_src/COPYING) (multiple)<commit_msg>List only the functions in README.md<commit_after># Cmark

[![Hex.pm package version](https://img.shields.io/hexpm/v/cmark.svg?style=flat-square)](https://hex.pm/packages/cmark)
[![Hex.pm package docs](https://img.shields.io/badge/hex-docs-orange.svg?style=flat-square)](http://hexdocs.pm/cmark/)
[![Hex.pm package license](https://img.shields.io/hexpm/l/cmark.svg?style=flat-square)](https://github.com/asaaki/cmark.ex/blob/master/LICENSE)
[![Build Status (master)](https://img.shields.io/travis/asaaki/cmark.ex/master.svg?style=flat-square)](https://travis-ci.org/asaaki/cmark.ex)
[![Coverage Status (master)](https://img.shields.io/coveralls/asaaki/cmark.ex/master.svg?style=flat-square)](https://coveralls.io/r/asaaki/cmark.ex)
[![Inline docs](http://inch-ci.org/github/asaaki/cmark.ex.svg?branch=master&style=flat-square)](http://inch-ci.org/github/asaaki/cmark.ex)

Elixir NIF for [cmark (C)](https://github.com/jgm/cmark), a parser library following the [CommonMark](http://commonmark.org/) spec.

## CommonMark

> A strongly specified, highly compatible implementation of Markdown

For more information visit <http://commonmark.org/>.

## Install

### Prerequisites

You need a C compiler like `gcc` or `clang`.

### mix.exs

Add this to your dependencies:

```elixir
{:cmark, "~> 0.6"}
```

## Usage

### Quick example

```elixir
Cmark.to_html "a markdown string"
#=> "<p>a markdown string</p>\n"
```

### Available functions

- `Cmark.to_html/1`
- `Cmark.to_html/2`
- `Cmark.to_html/3`
- `Cmark.to_html_each/3`
- `Cmark.to_xml/1`
- `Cmark.to_xml/2`
- `Cmark.to_xml/3`
- `Cmark.to_xml_each/3`
- `Cmark.to_man/1`
- `Cmark.to_man/2`
- `Cmark.to_man/3`
- `Cmark.to_man_each/3`
- `Cmark.to_commonmark/1`
- `Cmark.to_commonmark/2`
- `Cmark.to_commonmark/3`
- `Cmark.to_commonmark_each/3`
- `Cmark.to_latex/1`
- `Cmark.to_latex/2`
- `Cmark.to_latex/3`
- `Cmark.to_latex_each/3`

## Documentation

Latest API docs can be found at: <http://hexdocs.pm/cmark/0.6.2/Cmark.html>

## Licenses

- Cmark.ex: [LICENSE](./LICENSE) (MIT)
- cmark (C): [c_src/COPYING](./c_src/COPYING) (multiple)
{'fraction_non_alphanumeric': 0.21916118421052633, 'fraction_numerical': 0.01069078947368421, 'mean_word_length': 4.683411214953271, 'pattern_counts': {'":': 0, '<': 35, '<?xml version=': 0, '>': 57, 'https://': 21, 'lorem ipsum': 0, 'www.': 0, 'xml': 6}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4241254', 'n_tokens_mistral': 2050, 'n_tokens_neox': 1980, 'n_words': 304}