@@ -104,7 +104,7 @@ anyEnvironment = try (do
104104
105105-- | Process LaTeX preamble, extracting metadata
106106processLaTeXPreamble = do
107− manyTill (choice [bibliographic, comment, unknownCommand]) (try (string "\\begin{document}"))
107+ manyTill (choice [bibliographic, comment, unknownCommand, nullBlock]) (try (string "\\begin{document}"))
108108 spaces
109109
110110-- | Parse LaTeX and return 'Pandoc'.
@@ -454,7 +454,9 @@ sect = try (do
454454 string "\\S"
455455 return (Str [chr 167]))
456456
457−escapedChar = escaped (oneOf " $%^&_#{}")
457+escapedChar = do
458+ result <- escaped (oneOf " $%^&_#{}\n")
459+ return (if result == Str "\n" then Str " " else result)
458460
459461unescapedChar = do -- ignore standalone, nonescaped special characters
460462 oneOf "$^&_#{}|<>"
@@ -561,7 +563,11 @@ image = try (do
561563 return (Image [Str "image"] src))
562564
563565footnote = try (do
564− ("footnote", _, (contents:[])) <- command
566+ (name, _, (contents:[])) <- command
567+ if ((name == "footnote") || (name == "thanks")) then
568+ string ""
569+ else
570+ fail "not a footnote or thanks command"
565571 let contents' = stripFirstAndLast contents
566572 let blocks = case runParser parseBlocks defaultParserState "footnote" contents of
567573 Left err -> error $ "Input:\n" ++ show contents' ++