git.iko.soy/typeable/pandoc
on master help sign in
Minor improvements to LaTeX reader:
6536e64fiddlosopher
src/Text/Pandoc/Readers/LaTeX.hs+9−3
@@ -104,7 +104,7 @@ anyEnvironment = try (do
104
104
105-- | Process LaTeX preamble, extracting metadata
105-- | Process LaTeX preamble, extracting metadata
106processLaTeXPreamble = do
106processLaTeXPreamble = do
107− manyTill (choice [bibliographic, comment, unknownCommand]) (try (string "\\begin{document}"))
107+ manyTill (choice [bibliographic, comment, unknownCommand, nullBlock]) (try (string "\\begin{document}"))
108 spaces
108 spaces
109
109
110-- | Parse LaTeX and return 'Pandoc'.
110-- | Parse LaTeX and return 'Pandoc'.
@@ -454,7 +454,9 @@ sect = try (do
454 string "\\S"
454 string "\\S"
455 return (Str [chr 167]))
455 return (Str [chr 167]))
456
456
457−escapedChar = escaped (oneOf " $%^&_#{}")
457+escapedChar = do
458+ result <- escaped (oneOf " $%^&_#{}\n")
459+ return (if result == Str "\n" then Str " " else result)
458
460
459unescapedChar = do -- ignore standalone, nonescaped special characters
461unescapedChar = do -- ignore standalone, nonescaped special characters
460 oneOf "$^&_#{}|<>"
462 oneOf "$^&_#{}|<>"
@@ -561,7 +563,11 @@ image = try (do
561 return (Image [Str "image"] src))
563 return (Image [Str "image"] src))
562
564
563footnote = try (do
565footnote = 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"
565 let contents' = stripFirstAndLast contents
571 let contents' = stripFirstAndLast contents
566 let blocks = case runParser parseBlocks defaultParserState "footnote" contents of
572 let blocks = case runParser parseBlocks defaultParserState "footnote" contents of
567 Left err -> error $ "Input:\n" ++ show contents' ++
573 Left err -> error $ "Input:\n" ++ show contents' ++