From 6536e641288103b9554514d5bd4454b14592ee44 Mon Sep 17 00:00:00 2001 From: fiddlosopher Date: Mon, 27 Nov 2006 06:51:03 +0000 Subject: Minor improvements to LaTeX reader: + added nullBlock to preamble parsing, so we can handle unusual things like pure TeX + modified escapedChar to allow a \ at the end of line to count as escaped whitespace + treat "thanks" commands as footnotes git-svn-id: https://pandoc.googlecode.com/svn/trunk@146 788f1e2b-df1e-0410-8736-df70ead52e1b --- src/Text/Pandoc/Readers/LaTeX.hs | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'src/Text/Pandoc/Readers/LaTeX.hs') diff --git a/src/Text/Pandoc/Readers/LaTeX.hs b/src/Text/Pandoc/Readers/LaTeX.hs index ab87b89f0..3ab598bac 100644 --- a/src/Text/Pandoc/Readers/LaTeX.hs +++ b/src/Text/Pandoc/Readers/LaTeX.hs @@ -104,7 +104,7 @@ anyEnvironment = try (do -- | Process LaTeX preamble, extracting metadata processLaTeXPreamble = do - manyTill (choice [bibliographic, comment, unknownCommand]) (try (string "\\begin{document}")) + manyTill (choice [bibliographic, comment, unknownCommand, nullBlock]) (try (string "\\begin{document}")) spaces -- | Parse LaTeX and return 'Pandoc'. @@ -454,7 +454,9 @@ sect = try (do string "\\S" return (Str [chr 167])) -escapedChar = escaped (oneOf " $%^&_#{}") +escapedChar = do + result <- escaped (oneOf " $%^&_#{}\n") + return (if result == Str "\n" then Str " " else result) unescapedChar = do -- ignore standalone, nonescaped special characters oneOf "$^&_#{}|<>" @@ -561,7 +563,11 @@ image = try (do return (Image [Str "image"] src)) footnote = try (do - ("footnote", _, (contents:[])) <- command + (name, _, (contents:[])) <- command + if ((name == "footnote") || (name == "thanks")) then + string "" + else + fail "not a footnote or thanks command" let contents' = stripFirstAndLast contents let blocks = case runParser parseBlocks defaultParserState "footnote" contents of Left err -> error $ "Input:\n" ++ show contents' ++ -- cgit v1.2.3