mirror of
https://github.com/jgm/pandoc.git
synced 2026-09-22 07:25:36 +00:00
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:
@@ -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
|
||||
--
|
||||
|
||||
Reference in New Issue
Block a user