git.iko.soy/typeable/pandoc
on master help sign in
LaTeX reader: more robust parsing of bracketed options.

Improves on 9a40976. Closes #6873.

commit7db2cf5d2f637fc73377e32af776002e3670ef50 authorJohn MacFarlane <jgm@berkeley.edu> dateSat 21 Nov 2020, 12:24 (6 years ago) parentfec8223
2 files changed+15−3
src/Text/Pandoc/Readers/LaTeX.hs+8−3 test/command/6873.md+7
src/Text/Pandoc/Readers/LaTeX.hs+8−3
@@ -559,9 +559,14 @@ tok = try $ spaces >> grouped inline <|> inlineCommand' <|> singleChar'
559559 return $ str t
560560
561561opt :: PandocMonad m => LP m Inlines
562−opt = bracketed inline
563− <|>
564− (str . T.dropWhile (=='[') . T.dropWhileEnd (==']') <$> rawopt)
562+opt = do
563+ toks <- try (sp *> bracketedToks <* sp)
564+ -- now parse the toks as inlines
565+ st <- getState
566+ parsed <- runParserT (mconcat <$> many inline) st "bracketed option" toks
567+ case parsed of
568+ Right result -> return result
569+ Left e -> throwError $ PandocParsecError (untokenize toks) e
565570
566571paropt :: PandocMonad m => LP m Inlines
567572paropt = parenWrapped inline
test/command/6873.mdnew file+7
@@ -0,0 +1,7 @@
1+```
2+% pandoc -f latex -t native --citeproc
3+\cite[„Etwas […{]} auslassen“]{key}
4+^D
5+[WARNING] Citeproc: citation key not found
6+[Para [Cite [Citation {citationId = "key", citationPrefix = [], citationSuffix = [Str "\8222Etwas",Space,Str "[\8230",Span ("",[],[]) [Str "]"],Space,Str "auslassen\8220"], citationMode = NormalCitation, citationNoteNum = 0, citationHash = 0}] [Str "(",Strong [Str "key?"],Str "\8222Etwas",Space,Str "[\8230",Span ("",[],[]) [Str "]"],Space,Str "auslassen\8220)"]]]
7+```