@@ -189,25 +189,19 @@ hrule = oneOfStrings [ "\\begin{center}\\rule{3in}{0.4pt}\\end{center}\n\n",
189189--
190190
191191codeBlock :: GenParser Char st Block
192−codeBlock = codeBlock1 <|> codeBlock2
192+codeBlock = choice $ map codeBlockWith ["verbatim", "Verbatim", "code"]
193+-- Note: Verbatim is from fancyvrb. code is used by literate Haskell.
193194
194−codeBlock1 :: GenParser Char st Block
195−codeBlock1 = try $ do
196− string "\\begin{verbatim}" -- don't use begin function because it
197− -- gobbles whitespace
195+codeBlockWith :: String -> GenParser Char st Block
196+codeBlockWith env = try $ do
197+ string ("\\begin{" ++ env ++ "}") -- don't use begin function because it
198+ -- gobbles whitespace
198199 optional blanklines -- we want to gobble blank lines, but not
199200 -- leading space
200− contents <- manyTill anyChar (try (string "\\end{verbatim}"))
201+ contents <- manyTill anyChar (try (string $ "\\end{" ++ env ++ "}"))
201202 spaces
202− return $ CodeBlock ("",[],[]) (stripTrailingNewlines contents)
203−
204−codeBlock2 :: GenParser Char st Block
205−codeBlock2 = try $ do
206− string "\\begin{Verbatim}" -- used by fancyvrb package
207− optional blanklines
208− contents <- manyTill anyChar (try (string "\\end{Verbatim}"))
209− spaces
210− return $ CodeBlock ("",[],[]) (stripTrailingNewlines contents)
203+ let classes = if env == "code" then ["haskell"] else []
204+ return $ CodeBlock ("",classes,[]) (stripTrailingNewlines contents)
211205
212206--
213207-- block quotes