@@ -47,7 +47,7 @@ readLaTeX :: ParserState -- ^ Parser state, including options for parser
47readLaTeX = readWith parseLaTeX
47readLaTeX = readWith parseLaTeX
49-- characters with special meaning
49-- characters with special meaning
50−specialChars = "\\$%^&_~#{}\n \t|<>'\"-"
50+specialChars = "\\`$%^&_~#{}\n \t|<>'\"-"
53-- utility functions
53-- utility functions
@@ -69,7 +69,7 @@ isArg other = False
69commandArgs = many optOrArg
69commandArgs = many optOrArg
71-- | Parses LaTeX command, returns (name, star, list of options or arguments).
71-- | Parses LaTeX command, returns (name, star, list of options or arguments).
72−command = try $ do
72+command = do
74 name <- many1 alphaNum
74 name <- many1 alphaNum
75 star <- option "" (string "*") -- some commands have starred versions
75 star <- option "" (string "*") -- some commands have starred versions
@@ -152,16 +152,15 @@ block = choice [ hrule
152-- header blocks
152-- header blocks
155−header = choice (map headerLevel (enumFromTo 1 5)) <?> "header"
155+header = try $ do
157−headerLevel n = try $ do
157+ subs <- many (try (string "sub"))
158− let subs = concat $ replicate (n - 1) "sub"
159− string ("\\" ++ subs ++ "section")
158+ string "section"
160 optional (char '*')
159 optional (char '*')
162 title <- manyTill inline (char '}')
161 title <- manyTill inline (char '}')
164− return $ Header n (normalizeSpaces title)
163+ return $ Header (length subs + 1) (normalizeSpaces title)
167-- hrule block
166-- hrule block
@@ -386,7 +385,18 @@ comment = try $ char '%' >> manyTill anyChar newline >> spaces >> return Null
389−inline = choice [ strong
388+inline = choice [ str
391 , strikeout
401 , strikeout
392 , superscript
402 , superscript
@@ -394,27 +404,17 @@ inline = choice [ strong
411 , footnote
410 , footnote
412 , rawLaTeXInline
414 , rawLaTeXInline
413 , escapedChar
415 , escapedChar
414 , unescapedChar
416 , unescapedChar
417− , whitespace ] <?> "inline"
417+ ] <?> "inline"
419accentedChar = normalAccentedChar <|> specialAccentedChar
419accentedChar = normalAccentedChar <|> specialAccentedChar
@@ -492,7 +492,7 @@ escapedChar = do
492 return $ if result == Str "\n" then Str " " else result
492 return $ if result == Str "\n" then Str " " else result
494-- ignore standalone, nonescaped special characters
494-- ignore standalone, nonescaped special characters
495−unescapedChar = oneOf "$^&_#{}|<>" >> return (Str "")
495+unescapedChar = oneOf "`$^&_#{}|<>" >> return (Str "")
497specialChar = choice [ backslash, tilde, caret, bar, lt, gt ]
497specialChar = choice [ backslash, tilde, caret, bar, lt, gt ]