diff options
author | John MacFarlane <jgm@berkeley.edu> | 2020-11-21 12:24:37 -0800 |
---|---|---|
committer | John MacFarlane <jgm@berkeley.edu> | 2020-11-21 12:24:37 -0800 |
commit | 7db2cf5d2f637fc73377e32af776002e3670ef50 (patch) | |
tree | 39bc52667913a07c3be172c4641b317c8f8ba411 /src/Text | |
parent | fec8223d3a6979f675513300b2211c6235b8bccd (diff) | |
download | pandoc-7db2cf5d2f637fc73377e32af776002e3670ef50.tar.gz |
LaTeX reader: more robust parsing of bracketed options.
Improves on 9a40976. Closes #6873.
Diffstat (limited to 'src/Text')
-rw-r--r-- | src/Text/Pandoc/Readers/LaTeX.hs | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/src/Text/Pandoc/Readers/LaTeX.hs b/src/Text/Pandoc/Readers/LaTeX.hs index 2ec191154..9b6cc0e3f 100644 --- a/src/Text/Pandoc/Readers/LaTeX.hs +++ b/src/Text/Pandoc/Readers/LaTeX.hs @@ -559,9 +559,14 @@ tok = try $ spaces >> grouped inline <|> inlineCommand' <|> singleChar' return $ str t opt :: PandocMonad m => LP m Inlines -opt = bracketed inline - <|> - (str . T.dropWhile (=='[') . T.dropWhileEnd (==']') <$> rawopt) +opt = do + toks <- try (sp *> bracketedToks <* sp) + -- now parse the toks as inlines + st <- getState + parsed <- runParserT (mconcat <$> many inline) st "bracketed option" toks + case parsed of + Right result -> return result + Left e -> throwError $ PandocParsecError (untokenize toks) e paropt :: PandocMonad m => LP m Inlines paropt = parenWrapped inline |