File: README.md

package info (click to toggle)
haskell-cmark 0.6%2Bds1-3
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 132 kB
  • sloc: haskell: 48; makefile: 4
file content (70 lines) | stat: -rw-r--r-- 3,233 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
cmark-hs
========

This package provides Haskell bindings for [libcmark], the reference
parser for [CommonMark], a fully specified variant of Markdown.
It includes sources for [libcmark] and does not require prior
installation of the C library.

cmark provides the following advantages over existing Markdown
libraries for Haskell:

  - **Speed:** cmark can render a Markdown version of *War and Peace* in
    the blink of an eye.  Conversion speed is on par with the
    [sundown] library, though we were unable to benchmark precisely,
    because [sundown] raised a malloc error when compiled into our
    benchmark suite. Relative to other Haskell Markdown libraries:
    cmark was 82 times faster than [cheapskate], 59 times faster than
    [markdown], 105 times faster than [pandoc], and 3 times faster
    than [discount].

  - **Memory footprint:**  Memory footprint is on par with [sundown].
    On one sample, the library uses a fourth the memory that [markdown]
    uses, and less than a tenth the memory that [pandoc] uses.

  - **Robustness:**  cmark can handle whatever is thrown at it,
    without the exponential blowups in parsing time that sometimes afflict
    other libraries.  (The input `bench/full-sample.md`,
    for example, causes both [pandoc] and [markdown] to grind to a
    halt.)  [libcmark] has been extensively fuzz-tested.

  - **Accuracy:**  cmark passes the CommonMark spec's suite of over
    600 conformance tests.

  - **Standardization:**  Since there is a spec and a comprehensive suite
    of tests, we can have a high degree of confidence that any two
    CommonMark implementations will behave the same.  Thus, for
    example, one could use this library for server-side rendering
    and [commonmark.js] for client-side previewing.

  - **Multiple renderers.**  Output in HTML, groff man, LaTeX, CommonMark,
    and a custom XML format is supported. And it is easy to write new
    renderers to support other formats.

  - **Ease of installation:** cmark is portable and has minimal
    dependencies.

cmark does not provide Haskell versions of the whole [libcmark]
API, which is built around mutable `cmark_node` objects.  Instead, it
provides functions for converting CommonMark to HTML (and other
formats), and a function for converting CommonMark to a `Node`
tree that can be processed further using Haskell.

**A note on security:**  This library does not attempt to sanitize
HTML output.  We recommend using [xss-sanitize] to filter the output,
or enabling `optSafe` to filter out all raw HTML and potentially
dangerous URLs.

**A note on stability:**  There is a good chance the API will change
significantly after this early release.

[CommonMark]: http://commonmark.org
[libcmark]: http://github.com/jgm/cmark
[benchmarks]: https://github.com/jgm/cmark/blob/master/benchmarks.md
[cheapskate]: https://hackage.haskell.org/package/cheapskate
[pandoc]: https://hackage.haskell.org/package/pandoc
[sundown]: https://hackage.haskell.org/package/sundown
[markdown]: https://hackage.haskell.org/package/markdown
[commonmark.js]: http://github.com/jgm/commonmark.js
[xss-sanitize]: https://hackage.haskell.org/package/xss-sanitize
[discount]: https://hackage.haskell.org/package/discount