diff options
author | fiddlosopher <fiddlosopher@788f1e2b-df1e-0410-8736-df70ead52e1b> | 2007-08-29 21:03:26 +0000 |
---|---|---|
committer | fiddlosopher <fiddlosopher@788f1e2b-df1e-0410-8736-df70ead52e1b> | 2007-08-29 21:03:26 +0000 |
commit | 14dc5206697539cd8f9afc2b5c640ed2df319a1a (patch) | |
tree | aab37ede639c8601089a5835b8c1f1691be7ce6b /src/Text | |
parent | 451b426fd60d1e400eb2d1dae17533fdf4eb6c25 (diff) | |
download | pandoc-14dc5206697539cd8f9afc2b5c640ed2df319a1a.tar.gz |
Cleaned up LaTeX reader.
Rearranged order of parsers in inline for slight speed improvement.
Added ` to special characters and 'unescapedChar'.
git-svn-id: https://pandoc.googlecode.com/svn/trunk@960 788f1e2b-df1e-0410-8736-df70ead52e1b
Diffstat (limited to 'src/Text')
-rw-r--r-- | src/Text/Pandoc/Readers/LaTeX.hs | 48 |
1 files changed, 24 insertions, 24 deletions
diff --git a/src/Text/Pandoc/Readers/LaTeX.hs b/src/Text/Pandoc/Readers/LaTeX.hs index 729f597fa..58e0fa21a 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 @@ -69,7 +69,7 @@ isArg other = False commandArgs = many optOrArg -- | Parses LaTeX command, returns (name, star, list of options or arguments). -command = try $ do +command = do char '\\' name <- many1 alphaNum star <- option "" (string "*") -- some commands have starred versions @@ -152,16 +152,15 @@ block = choice [ hrule -- header blocks -- -header = choice (map headerLevel (enumFromTo 1 5)) <?> "header" - -headerLevel n = try $ do - let subs = concat $ replicate (n - 1) "sub" - string ("\\" ++ subs ++ "section") +header = try $ do + char '\\' + subs <- many (try (string "sub")) + string "section" optional (char '*') char '{' title <- manyTill inline (char '}') spaces - return $ Header n (normalizeSpaces title) + return $ Header (length subs + 1) (normalizeSpaces title) -- -- hrule block @@ -386,7 +385,18 @@ comment = try $ char '%' >> manyTill anyChar newline >> spaces >> return Null -- inline -- -inline = choice [ strong +inline = choice [ str + , endline + , whitespace + , quoted + , apostrophe + , spacer + , strong + , math + , ellipses + , emDash + , enDash + , hyphen , emph , strikeout , superscript @@ -394,27 +404,17 @@ inline = choice [ strong , ref , lab , code - , linebreak - , spacer - , math - , ellipses - , emDash - , enDash - , hyphen - , quoted - , apostrophe - , accentedChar - , specialChar , url , link , image , footnote + , linebreak + , accentedChar + , specialChar , rawLaTeXInline , escapedChar , unescapedChar - , str - , endline - , whitespace ] <?> "inline" + ] <?> "inline" accentedChar = normalAccentedChar <|> specialAccentedChar @@ -492,7 +492,7 @@ escapedChar = do return $ if result == Str "\n" then Str " " else result -- ignore standalone, nonescaped special characters -unescapedChar = oneOf "$^&_#{}|<>" >> return (Str "") +unescapedChar = oneOf "`$^&_#{}|<>" >> return (Str "") specialChar = choice [ backslash, tilde, caret, bar, lt, gt ] |