LaTeX reader: handle table cells containing & in \verb.

Closes #7129.
This commit is contained in:
John MacFarlane 2021-03-07 15:49:02 -08:00
parent 75d4bca862
commit 5aa73bd0a2
2 changed files with 33 additions and 1 deletions

View file

@ -134,6 +134,11 @@ parseTableRow :: PandocMonad m
-> LP m Row
parseTableRow blocks inline envname prefsufs = do
notFollowedBy (spaces *> end_ envname)
-- contexts that can contain & that is not colsep:
let canContainAmp (Tok _ (CtrlSeq "begin") _) = True
canContainAmp (Tok _ (CtrlSeq "verb") _) = True
canContainAmp (Tok _ (CtrlSeq "Verb") _) = True
canContainAmp _ = False
-- add prefixes and suffixes in token stream:
let celltoks (pref, suff) = do
prefpos <- getPosition
@ -142,7 +147,7 @@ parseTableRow blocks inline envname prefsufs = do
((lookAhead (controlSeq "parbox") >>
void blocks) -- #5711
<|>
(lookAhead (controlSeq "begin") >> void inline)
(lookAhead (satisfyTok canContainAmp) >> void inline)
<|>
(lookAhead (symbol '$') >> void inline))
<|>

27
test/command/7129.md Normal file
View file

@ -0,0 +1,27 @@
```
% pandoc -f latex -t native
\begin{tabular}{ll} \hline
FOO & BAR \\ \hline
foo & \verb|b&r| \\ \hline
\end{tabular}
^D
[Table ("",[],[]) (Caption Nothing
[])
[(AlignLeft,ColWidthDefault)
,(AlignLeft,ColWidthDefault)]
(TableHead ("",[],[])
[Row ("",[],[])
[Cell ("",[],[]) AlignDefault (RowSpan 1) (ColSpan 1)
[Plain [Str "FOO"]]
,Cell ("",[],[]) AlignDefault (RowSpan 1) (ColSpan 1)
[Plain [Str "BAR"]]]])
[(TableBody ("",[],[]) (RowHeadColumns 0)
[]
[Row ("",[],[])
[Cell ("",[],[]) AlignDefault (RowSpan 1) (ColSpan 1)
[Plain [Str "foo"]]
,Cell ("",[],[]) AlignDefault (RowSpan 1) (ColSpan 1)
[Plain [Code ("",[],[]) "b&r"]]]])]
(TableFoot ("",[],[])
[])]
```