git.iko.soy/typeable/pandoc
on master help sign in
LaTeX reader: Added parser for literate haskell code blocks.
c815c2ffiddlosopher
Text/Pandoc/Readers/LaTeX.hs+9−3
@@ -188,9 +188,9 @@ hrule = oneOfStrings [ "\\begin{center}\\rule{3in}{0.4pt}\\end{center}\n\n",
188-- code blocks
188-- code blocks
189--
189--
190
190
191−codeBlock :: GenParser Char st Block
191+codeBlock :: GenParser Char ParserState Block
192−codeBlock = choice $ map codeBlockWith ["verbatim", "Verbatim", "code"]
192+codeBlock = codeBlockWith "verbatim" <|> codeBlockWith "Verbatim" <|> lhsCodeBlock
193−-- Note: Verbatim is from fancyvrb. code is used by literate Haskell.
193+-- Note: Verbatim is from fancyvrb.
194
194
195codeBlockWith :: String -> GenParser Char st Block
195codeBlockWith :: String -> GenParser Char st Block
196codeBlockWith env = try $ do
196codeBlockWith env = try $ do
@@ -203,6 +203,12 @@ codeBlockWith env = try $ do
203 let classes = if env == "code" then ["haskell"] else []
203 let classes = if env == "code" then ["haskell"] else []
204 return $ CodeBlock ("",classes,[]) (stripTrailingNewlines contents)
204 return $ CodeBlock ("",classes,[]) (stripTrailingNewlines contents)
205
205
206+lhsCodeBlock :: GenParser Char ParserState Block
207+lhsCodeBlock = do
208+ failUnlessLHS
209+ (CodeBlock (_,_,_) cont) <- codeBlockWith "code"
210+ return $ CodeBlock ("", ["haskell"], []) cont
211+
206--
212--
207-- block quotes
213-- block quotes
208--
214--