markdown PEG (parsing expression grammar)

John MacFarlane jgm at
Sun Apr 6 13:50:39 EDT 2008

There's been a lot of discussion on this list about creating a formal
grammar for markdown. I had a go at writing a [parsing expression
grammar] for markdown. I used Haskell and John Meacham's Frisby PEG
parsing library, but it should not be too hard to port the grammar
to PEG libraries in other languages.

[parsing expression grammar]:

The code is at <>.
All that is required to compile it is the GHC haskell compiler.
The grammar itself begins at line 68 of Markdown.hs:

This implementation is not particularly fast, though it is still
faster than It should be fairly easy to modify and extend,
though, and the grammar provides a precise specification of (one
interpretation of!) the syntax of markdown, which might be a useful
basis for discussion.


More information about the Markdown-Discuss mailing list