From 1b6c9733eeda3f4d3486b90f4712d9e6d3a4624b Mon Sep 17 00:00:00 2001 From: John MacFarlane Date: Wed, 20 Jul 2016 11:18:24 -0700 Subject: LaTeX reader: more robust parsing of unknown environments. We no longer fail on things like `^` inside options for tikz. Closes #3026. --- src/Text/Pandoc/Readers/LaTeX.hs | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'src/Text/Pandoc') 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) -- cgit v1.2.3