diff options
author | John MacFarlane <jgm@berkeley.edu> | 2019-08-27 10:48:02 -0700 |
---|---|---|
committer | John MacFarlane <jgm@berkeley.edu> | 2019-08-27 10:48:02 -0700 |
commit | fba1296fd1ac6427d19f537c4b8afda9fc60ac75 (patch) | |
tree | cbe8ec4db995419d92a406fbd11be5ea8acd4e16 /src | |
parent | 167fc4bc8732b72cccda0c37139fee3ab94b05cb (diff) | |
download | pandoc-fba1296fd1ac6427d19f537c4b8afda9fc60ac75.tar.gz |
LaTeX reader: fix `\\` in `\parbox` inside a table cell.
Closes #5711.
Diffstat (limited to 'src')
-rw-r--r-- | src/Text/Pandoc/Readers/LaTeX.hs | 21 |
1 files changed, 18 insertions, 3 deletions
diff --git a/src/Text/Pandoc/Readers/LaTeX.hs b/src/Text/Pandoc/Readers/LaTeX.hs index 25fd1198f..4e006fa8a 100644 --- a/src/Text/Pandoc/Readers/LaTeX.hs +++ b/src/Text/Pandoc/Readers/LaTeX.hs @@ -1749,10 +1749,21 @@ closing = do _ -> mempty return $ para (trimInlines contents) <> sigs +parbox :: PandocMonad m => LP m Blocks +parbox = try $ do + skipopts + braced -- size + oldInTableCell <- sInTableCell <$> getState + -- see #5711 + updateState $ \st -> st{ sInTableCell = False } + res <- grouped blocks + updateState $ \st -> st{ sInTableCell = oldInTableCell } + return res + blockCommands :: PandocMonad m => M.Map Text (LP m Blocks) blockCommands = M.fromList [ ("par", mempty <$ skipopts) - , ("parbox", skipopts >> braced >> grouped blocks) + , ("parbox", parbox) , ("title", mempty <$ (skipopts *> (grouped inline >>= addMeta "title") <|> (grouped block >>= addMeta "title"))) @@ -2269,9 +2280,13 @@ parseTableRow envname prefsufs = do -- add prefixes and suffixes in token stream: let celltoks (pref, suff) = do prefpos <- getPosition - contents <- many (notFollowedBy + contents <- mconcat <$> + many ( snd <$> withRaw (controlSeq "parbox" >> parbox) -- #5711 + <|> + (do notFollowedBy (() <$ amp <|> () <$ lbreak <|> end_ envname) - >> anyTok) + count 1 anyTok) ) + suffpos <- getPosition option [] (count 1 amp) return $ map (setpos prefpos) pref ++ contents ++ map (setpos suffpos) suff |