From e4dedad1c0f435cbdc854a851e2df5cbc668c7b7 Mon Sep 17 00:00:00 2001 From: Puneeth Chaganti Date: Thu, 30 Dec 2010 00:48:55 +0530 Subject: Added support for listings package code blocks and inline code. --- src/Text/Pandoc/Readers/LaTeX.hs | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/Text/Pandoc/Readers/LaTeX.hs b/src/Text/Pandoc/Readers/LaTeX.hs index 6006aac5b..561038081 100644 --- a/src/Text/Pandoc/Readers/LaTeX.hs +++ b/src/Text/Pandoc/Readers/LaTeX.hs @@ -211,7 +211,7 @@ hrule = oneOfStrings [ "\\begin{center}\\rule{3in}{0.4pt}\\end{center}\n\n", -- codeBlock :: GenParser Char ParserState Block -codeBlock = codeBlockWith "verbatim" <|> codeBlockWith "Verbatim" <|> lhsCodeBlock +codeBlock = codeBlockWith "verbatim" <|> codeBlockWith "Verbatim" <|> codeBlockWith "lstlisting" <|> lhsCodeBlock -- Note: Verbatim is from fancyvrb. codeBlockWith :: String -> GenParser Char st Block @@ -611,7 +611,7 @@ doubleQuote :: GenParser Char st Inline doubleQuote = char '"' >> return (Str "\"") code :: GenParser Char ParserState Inline -code = code1 <|> code2 <|> lhsInlineCode +code = code1 <|> code2 <|> code3 <|> lhsInlineCode code1 :: GenParser Char st Inline code1 = try $ do @@ -626,6 +626,13 @@ code2 = try $ do result <- manyTill (noneOf "\\\n~$%^&{}") (char '}') return $ Code result +code3 :: GenParser Char st Inline +code3 = try $ do + string "\\lstinline" + marker <- anyChar + result <- manyTill anyChar (char marker) + return $ Code $ removeLeadingTrailingSpace result + lhsInlineCode :: GenParser Char ParserState Inline lhsInlineCode = try $ do failUnlessLHS -- cgit v1.2.3