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
This commit is contained in:
fiddlosopher 2006-11-27 06:51:03 +00:00
parent 7384774d83
commit 6536e64128

View file

@ -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' ++