aboutsummaryrefslogtreecommitdiff
path: root/src/Text/Pandoc/Readers/LaTeX.hs
diff options
context:
space:
mode:
authorfiddlosopher <fiddlosopher@788f1e2b-df1e-0410-8736-df70ead52e1b>2006-11-27 06:51:03 +0000
committerfiddlosopher <fiddlosopher@788f1e2b-df1e-0410-8736-df70ead52e1b>2006-11-27 06:51:03 +0000
commit6536e641288103b9554514d5bd4454b14592ee44 (patch)
tree73e7e1502e564618f4c9a3bcc9a0ab6a936fffa9 /src/Text/Pandoc/Readers/LaTeX.hs
parent7384774d83c4773d2a19073b464e415f8c2859c9 (diff)
downloadpandoc-6536e641288103b9554514d5bd4454b14592ee44.tar.gz
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
Diffstat (limited to 'src/Text/Pandoc/Readers/LaTeX.hs')
-rw-r--r--src/Text/Pandoc/Readers/LaTeX.hs12
1 files changed, 9 insertions, 3 deletions
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' ++