diff options
author | fiddlosopher <fiddlosopher@788f1e2b-df1e-0410-8736-df70ead52e1b> | 2008-08-26 20:36:06 +0000 |
---|---|---|
committer | fiddlosopher <fiddlosopher@788f1e2b-df1e-0410-8736-df70ead52e1b> | 2008-08-26 20:36:06 +0000 |
commit | 4f14802831477eea7b67ef40e60ed7eec82f69a5 (patch) | |
tree | 95c4b1d41d7d8b87bfda1e562121e236bee1eb8d /Text/Pandoc | |
parent | a23f8ba5bdd6bc4da9f3c13d469477c801b020d7 (diff) | |
download | pandoc-4f14802831477eea7b67ef40e60ed7eec82f69a5.tar.gz |
LaTeX reader: Parse "code" environments as verbatim (lhs).
Refactored parsers for verbatim environments.
git-svn-id: https://pandoc.googlecode.com/svn/trunk@1414 788f1e2b-df1e-0410-8736-df70ead52e1b
Diffstat (limited to 'Text/Pandoc')
-rw-r--r-- | Text/Pandoc/Readers/LaTeX.hs | 24 |
1 files changed, 9 insertions, 15 deletions
diff --git a/Text/Pandoc/Readers/LaTeX.hs b/Text/Pandoc/Readers/LaTeX.hs index 883c1bbd1..647899acf 100644 --- a/Text/Pandoc/Readers/LaTeX.hs +++ b/Text/Pandoc/Readers/LaTeX.hs @@ -189,25 +189,19 @@ hrule = oneOfStrings [ "\\begin{center}\\rule{3in}{0.4pt}\\end{center}\n\n", -- codeBlock :: GenParser Char st Block -codeBlock = codeBlock1 <|> codeBlock2 +codeBlock = choice $ map codeBlockWith ["verbatim", "Verbatim", "code"] +-- Note: Verbatim is from fancyvrb. code is used by literate Haskell. -codeBlock1 :: GenParser Char st Block -codeBlock1 = try $ do - string "\\begin{verbatim}" -- don't use begin function because it - -- gobbles whitespace +codeBlockWith :: String -> GenParser Char st Block +codeBlockWith env = try $ do + string ("\\begin{" ++ env ++ "}") -- don't use begin function because it + -- gobbles whitespace optional blanklines -- we want to gobble blank lines, but not -- leading space - contents <- manyTill anyChar (try (string "\\end{verbatim}")) + contents <- manyTill anyChar (try (string $ "\\end{" ++ env ++ "}")) spaces - return $ CodeBlock ("",[],[]) (stripTrailingNewlines contents) - -codeBlock2 :: GenParser Char st Block -codeBlock2 = try $ do - string "\\begin{Verbatim}" -- used by fancyvrb package - optional blanklines - contents <- manyTill anyChar (try (string "\\end{Verbatim}")) - spaces - return $ CodeBlock ("",[],[]) (stripTrailingNewlines contents) + let classes = if env == "code" then ["haskell"] else [] + return $ CodeBlock ("",classes,[]) (stripTrailingNewlines contents) -- -- block quotes |