[Haskell-cafe] ANN: cheapskate 0.1, markdown parser

John MacFarlane jgm at berkeley.edu
Mon Jan 6 19:15:53 UTC 2014


I've released a new markdown library on Hackage:
http://hackage.haskell.org/package/cheapskate

This library is designed to be used in web applications.  It is small,
accurate, and fast, in pure Haskell with few dependencies.  All output
is sanitized through a whitelist by default.  It is designed to have
performance that varies linearly with the input size, even with garbage
input.  To illustrate:

% head -c 100000 /dev/urandom | iconv -f latin1 -t utf-8 | time cheapskate >/dev/null
cheapskate > /dev/null  0.15s user 0.01s system 82% cpu 0.199 total
% head -c 1000000 /dev/urandom | iconv -f latin1 -t utf-8 | time cheapskate >/dev/null
cheapskate > /dev/null  1.53s user 0.03s system 88% cpu 1.770 total
% head -c 10000000 /dev/urandom | iconv -f latin1 -t utf-8 | time cheapskate >/dev/null
cheapskate > /dev/null  15.50s user 0.20s system 89% cpu 17.632 total

This is a test that many markdown parsers fail (including my own pandoc
and the markdown package on Hackage).

Performance is about seven times faster than pandoc (with five times
less memory used), and about 25% faster than the markdown package on Hackage.

Generic functions are provided that allow transformations of the AST
prior to rendering (e.g., promotion of headers, insertion of syntax
highlighting, or the conversion of specially marked code blocks into
diagrams).

Several markdown extensions are supported, and sensible decisions have
been made about several aspects of markdown syntax that are left vague
by John Gruber's specification.  For details, see the README
at https://github.com/jgm/cheapskate.



More information about the Haskell-Cafe mailing list