From 1a4489ef30ed44965f98cf05114d38325f418a25 Mon Sep 17 00:00:00 2001 From: fiddlosopher Date: Wed, 15 Aug 2007 17:30:37 +0000 Subject: LaTeX reader: parse \texttt{} as code, as long as there's nothing fancy inside. git-svn-id: https://pandoc.googlecode.com/svn/trunk@846 788f1e2b-df1e-0410-8736-df70ead52e1b --- src/Text/Pandoc/Readers/LaTeX.hs | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'src/Text') diff --git a/src/Text/Pandoc/Readers/LaTeX.hs b/src/Text/Pandoc/Readers/LaTeX.hs index 4b91b528c..84bda1942 100644 --- a/src/Text/Pandoc/Readers/LaTeX.hs +++ b/src/Text/Pandoc/Readers/LaTeX.hs @@ -47,7 +47,7 @@ readLaTeX :: ParserState -- ^ Parser state, including options for parser readLaTeX = readWith parseLaTeX -- characters with special meaning -specialChars = "\\$%&^&_~#{}\n \t|<>'\"-" +specialChars = "\\$%^&_~#{}\n \t|<>'\"-" -- -- utility functions @@ -507,12 +507,19 @@ lt = try (string "\\textless") >> return (Str "<") gt = try (string "\\textgreater") >> return (Str ">") -code = try $ do +code = code1 <|> code2 + +code1 = try $ do string "\\verb" marker <- anyChar result <- manyTill anyChar (char marker) return $ Code $ removeLeadingTrailingSpace result +code2 = try $ do + string "\\texttt{" + result <- manyTill (noneOf "\\\n~$%^&{}") (char '}') + return $ Code result + emph = try $ oneOfStrings [ "\\emph{", "\\textit{" ] >> manyTill inline (char '}') >>= return . Emph -- cgit v1.2.3