Skip to content
100644 44 lines (32 sloc) 1.81 KB
cc77dec @jgm Added README.
1 Markdown.hs - an implementation of markdown in Haskell, using a PEG grammar.
2 (c) 2008 John MacFarlane, released under the GPL.
4 Markdown is a plain-text syntax for writing HTML (and potentially other
5 formats), by John Gruber (<>).
7 To build (using the GHC Haskell compiler):
9 ghc -O2 --make Markdown.hs
11 or just:
13 make
15 Markdown.hs uses John Meacham's Frisby PEG parsing library. This can
16 be found at <>, but for convenience
17 the required files are included in this directory. The XML formatting
18 library from Pandoc (<>).
19 is also included for convenience.
21 This is a first draft. I'm sure there are many ways in which it can be
22 improved. Currently it passes the Markdown 1.0.3 test suite, with the
23 exception of two small corner cases.
25 The grammar definition is the function 'doc' in Markdown.hs. It should
26 be easy to change and extend it. If you want to add new block or
27 inline elements, you'll also need to modify the definitions of 'Block'
28 and 'Inline', and add clauses to handle these to 'inlineToHtml' and
29 'blockToHtml'.
31 There are a couple of features of markdown that cannot be handled
32 straightforwardly in a PEG grammar; workarounds have been provided here.
33 The first is the syntax for code spans: text enclosed by equal-sized
34 sequences of backticks. I have simulated this by including separate
35 rules for sequences of backticks of length 1 to 10, but this doesn't
36 precisely capture the markdown rule. The second is the syntax for
37 indented blocks, e.g. in block quotes and lists. I have handled these
38 by having the parser return unparsed markdown text for the block
39 contents; the parser is then called again by the function 'blockToHtml'.
41 See LICENSE for license information for Markdown.hs and the other included
42 files.
Something went wrong with that request. Please try again.