aboutsummaryrefslogtreecommitdiff
path: root/Text
diff options
context:
space:
mode:
authorfiddlosopher <fiddlosopher@788f1e2b-df1e-0410-8736-df70ead52e1b>2008-09-06 20:45:53 +0000
committerfiddlosopher <fiddlosopher@788f1e2b-df1e-0410-8736-df70ead52e1b>2008-09-06 20:45:53 +0000
commitb422711451fb6520e9a23caee973bf2f36c237c6 (patch)
treeee9838aa0455dee853d3ba7015f8f9c86d064b6a /Text
parentae30b5ae3758122641b3188098a014210e0b6714 (diff)
downloadpandoc-b422711451fb6520e9a23caee973bf2f36c237c6.tar.gz
LaTeX reader: minor improvements.
+ parse '{}', if present, after \textless, \textgreater, \textbar, \textbackslash, \ldots. + Parse unescaped special characters verbatim rather than changing them to spaces. This way arguments of unknown commands will appear in braces. git-svn-id: https://pandoc.googlecode.com/svn/trunk@1424 788f1e2b-df1e-0410-8736-df70ead52e1b
Diffstat (limited to 'Text')
-rw-r--r--Text/Pandoc/Readers/LaTeX.hs16
1 files changed, 9 insertions, 7 deletions
diff --git a/Text/Pandoc/Readers/LaTeX.hs b/Text/Pandoc/Readers/LaTeX.hs
index 7c52650e6..d7d031595 100644
--- a/Text/Pandoc/Readers/LaTeX.hs
+++ b/Text/Pandoc/Readers/LaTeX.hs
@@ -412,6 +412,7 @@ unknownCommand = try $ do
char '\\'
letter
many (letter <|> digit)
+ optional (try $ string "{}")
spaces
return Null
@@ -542,15 +543,15 @@ escapedChar = do
result <- escaped (oneOf " $%&_#{}\n")
return $ if result == Str "\n" then Str " " else result
--- treat nonescaped special characters as spaces
+-- nonescaped special characters
unescapedChar :: GenParser Char st Inline
-unescapedChar = oneOf "`$^&_#{}|<>" >> return Space
+unescapedChar = oneOf "`$^&_#{}|<>" >>= return . (\c -> Str [c])
specialChar :: GenParser Char st Inline
specialChar = choice [ backslash, tilde, caret, bar, lt, gt, doubleQuote ]
backslash :: GenParser Char st Inline
-backslash = try (string "\\textbackslash") >> return (Str "\\")
+backslash = try (string "\\textbackslash") >> optional (try $ string "{}") >> return (Str "\\")
tilde :: GenParser Char st Inline
tilde = try (string "\\ensuremath{\\sim}") >> return (Str "~")
@@ -559,13 +560,13 @@ caret :: GenParser Char st Inline
caret = try (string "\\^{}") >> return (Str "^")
bar :: GenParser Char st Inline
-bar = try (string "\\textbar") >> return (Str "\\")
+bar = try (string "\\textbar") >> optional (try $ string "{}") >> return (Str "\\")
lt :: GenParser Char st Inline
-lt = try (string "\\textless") >> return (Str "<")
+lt = try (string "\\textless") >> optional (try $ string "{}") >> return (Str "<")
gt :: GenParser Char st Inline
-gt = try (string "\\textgreater") >> return (Str ">")
+gt = try (string "\\textgreater") >> optional (try $ string "{}") >> return (Str ">")
doubleQuote :: GenParser Char st Inline
doubleQuote = char '"' >> return (Str "\"")
@@ -631,7 +632,7 @@ doubleQuoteEnd :: CharParser st String
doubleQuoteEnd = try $ string "''"
ellipses :: GenParser Char st Inline
-ellipses = try $ string "\\ldots" >> optional (try (string "{}")) >>
+ellipses = try $ string "\\ldots" >> optional (try $ string "{}") >>
return Ellipses
enDash :: GenParser Char st Inline
@@ -756,4 +757,5 @@ rawLaTeXInline = try $ do
char '\\'
letter
many (letter <|> digit)
+ optional (try $ string "{}")
return $ Str ""