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:
parent
95c16bfa3b
commit
c815c2feab
1 changed files with 9 additions and 3 deletions
|
@ -188,9 +188,9 @@ hrule = oneOfStrings [ "\\begin{center}\\rule{3in}{0.4pt}\\end{center}\n\n",
|
||||||
-- code blocks
|
-- code blocks
|
||||||
--
|
--
|
||||||
|
|
||||||
codeBlock :: GenParser Char st Block
|
codeBlock :: GenParser Char ParserState Block
|
||||||
codeBlock = choice $ map codeBlockWith ["verbatim", "Verbatim", "code"]
|
codeBlock = codeBlockWith "verbatim" <|> codeBlockWith "Verbatim" <|> lhsCodeBlock
|
||||||
-- Note: Verbatim is from fancyvrb. code is used by literate Haskell.
|
-- Note: Verbatim is from fancyvrb.
|
||||||
|
|
||||||
codeBlockWith :: String -> GenParser Char st Block
|
codeBlockWith :: String -> GenParser Char st Block
|
||||||
codeBlockWith env = try $ do
|
codeBlockWith env = try $ do
|
||||||
|
@ -203,6 +203,12 @@ codeBlockWith env = try $ do
|
||||||
let classes = if env == "code" then ["haskell"] else []
|
let classes = if env == "code" then ["haskell"] else []
|
||||||
return $ CodeBlock ("",classes,[]) (stripTrailingNewlines contents)
|
return $ CodeBlock ("",classes,[]) (stripTrailingNewlines contents)
|
||||||
|
|
||||||
|
lhsCodeBlock :: GenParser Char ParserState Block
|
||||||
|
lhsCodeBlock = do
|
||||||
|
failUnlessLHS
|
||||||
|
(CodeBlock (_,_,_) cont) <- codeBlockWith "code"
|
||||||
|
return $ CodeBlock ("", ["haskell"], []) cont
|
||||||
|
|
||||||
--
|
--
|
||||||
-- block quotes
|
-- block quotes
|
||||||
--
|
--
|
||||||
|
|
Loading…
Reference in a new issue