aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJohn MacFarlane <jgm@berkeley.edu>2016-07-20 11:18:24 -0700
committerJohn MacFarlane <jgm@berkeley.edu>2016-07-20 11:18:24 -0700
commit1b6c9733eeda3f4d3486b90f4712d9e6d3a4624b (patch)
tree816a8ec331d9e19bdb044729c102ec93f6da54a8 /src
parent5611de1473116fb1383a97ba0bd4b0e3bf11ac9f (diff)
downloadpandoc-1b6c9733eeda3f4d3486b90f4712d9e6d3a4624b.tar.gz
LaTeX reader: more robust parsing of unknown environments.
We no longer fail on things like `^` inside options for tikz. Closes #3026.
Diffstat (limited to 'src')
-rw-r--r--src/Text/Pandoc/Readers/LaTeX.hs11
1 files changed, 9 insertions, 2 deletions
diff --git a/src/Text/Pandoc/Readers/LaTeX.hs b/src/Text/Pandoc/Readers/LaTeX.hs
index 8100a6823..dc460684e 100644
--- a/src/Text/Pandoc/Readers/LaTeX.hs
+++ b/src/Text/Pandoc/Readers/LaTeX.hs
@@ -859,8 +859,14 @@ tok = try $ grouped inline <|> inlineCommand <|> str <$> count 1 inlineChar
opt :: LP Inlines
opt = bracketed inline
+rawopt :: LP String
+rawopt = do
+ contents <- bracketed (many1 (noneOf "]") <|> try (string "\\]"))
+ optional sp
+ return $ "[" ++ contents ++ "]"
+
skipopts :: LP ()
-skipopts = skipMany (opt *> optional sp)
+skipopts = skipMany rawopt
inlineText :: LP Inlines
inlineText = str <$> many1 inlineChar
@@ -883,8 +889,9 @@ inlineEnvironment = try $ do
rawEnv :: String -> LP Blocks
rawEnv name = do
- let addBegin x = "\\begin{" ++ name ++ "}" ++ x
parseRaw <- getOption readerParseRaw
+ rawOptions <- mconcat <$> many rawopt
+ let addBegin x = "\\begin{" ++ name ++ "}" ++ rawOptions ++ x
if parseRaw
then (rawBlock "latex" . addBegin) <$>
(withRaw (env name blocks) >>= applyMacros' . snd)