diff options
author | fiddlosopher <fiddlosopher@788f1e2b-df1e-0410-8736-df70ead52e1b> | 2008-12-02 22:42:08 +0000 |
---|---|---|
committer | fiddlosopher <fiddlosopher@788f1e2b-df1e-0410-8736-df70ead52e1b> | 2008-12-02 22:42:08 +0000 |
commit | c815c2feabe76d32d10161fee69d296d6736bca9 (patch) | |
tree | aa6462ac6ea54488be8cfef1e6c400c8e63bb95b /Text/Pandoc/Readers | |
parent | 95c16bfa3b6e598bf7101c9915dac2ca62fb7889 (diff) | |
download | pandoc-c815c2feabe76d32d10161fee69d296d6736bca9.tar.gz |
LaTeX reader: Added parser for literate haskell code blocks.
git-svn-id: https://pandoc.googlecode.com/svn/trunk@1499 788f1e2b-df1e-0410-8736-df70ead52e1b
Diffstat (limited to 'Text/Pandoc/Readers')
-rw-r--r-- | Text/Pandoc/Readers/LaTeX.hs | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/Text/Pandoc/Readers/LaTeX.hs b/Text/Pandoc/Readers/LaTeX.hs index d2dff2d5a..b1148e07d 100644 --- a/Text/Pandoc/Readers/LaTeX.hs +++ b/Text/Pandoc/Readers/LaTeX.hs @@ -188,9 +188,9 @@ hrule = oneOfStrings [ "\\begin{center}\\rule{3in}{0.4pt}\\end{center}\n\n", -- code blocks -- -codeBlock :: GenParser Char st Block -codeBlock = choice $ map codeBlockWith ["verbatim", "Verbatim", "code"] --- Note: Verbatim is from fancyvrb. code is used by literate Haskell. +codeBlock :: GenParser Char ParserState Block +codeBlock = codeBlockWith "verbatim" <|> codeBlockWith "Verbatim" <|> lhsCodeBlock +-- Note: Verbatim is from fancyvrb. codeBlockWith :: String -> GenParser Char st Block codeBlockWith env = try $ do @@ -203,6 +203,12 @@ codeBlockWith env = try $ do let classes = if env == "code" then ["haskell"] else [] return $ CodeBlock ("",classes,[]) (stripTrailingNewlines contents) +lhsCodeBlock :: GenParser Char ParserState Block +lhsCodeBlock = do + failUnlessLHS + (CodeBlock (_,_,_) cont) <- codeBlockWith "code" + return $ CodeBlock ("", ["haskell"], []) cont + -- -- block quotes -- |