LaTeX reader: Added parser for literate haskell code blocks.

git-svn-id: https://pandoc.googlecode.com/svn/trunk@1499 788f1e2b-df1e-0410-8736-df70ead52e1b
This commit is contained in:
fiddlosopher 2008-12-02 22:42:08 +00:00
parent 95c16bfa3b
commit c815c2feab

View file

@ -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
--