From 05a23af76d30effa7e40e0346479fb57ed4804d3 Mon Sep 17 00:00:00 2001 From: Albert Krewinkel Date: Thu, 4 May 2023 11:30:27 +0200 Subject: [PATCH] LaTeX reader: ignore args to column type in `\multicolumn`. The `\multicolumn` command takes the column type as the second argument. Types like `p` take an additional argument, which is now ignored and no longer causes the table parser to fail. Fixes: #8789 --- src/Text/Pandoc/Readers/LaTeX/Table.hs | 2 +- test/command/8789.md | 42 ++++++++++++++++++++++++++ 2 files changed, 43 insertions(+), 1 deletion(-) create mode 100644 test/command/8789.md diff --git a/src/Text/Pandoc/Readers/LaTeX/Table.hs b/src/Text/Pandoc/Readers/LaTeX/Table.hs index def516d6b..e6e3fc436 100644 --- a/src/Text/Pandoc/Readers/LaTeX/Table.hs +++ b/src/Text/Pandoc/Readers/LaTeX/Table.hs @@ -189,7 +189,7 @@ cellAlignment :: PandocMonad m => LP m Alignment cellAlignment = skipMany (symbol '|') *> alignment <* skipMany (symbol '|') where alignment = do - c <- untoken <$> singleChar + c <- untoken <$> singleChar <* optional braced -- ignore args return $ case c of "l" -> AlignLeft "r" -> AlignRight diff --git a/test/command/8789.md b/test/command/8789.md new file mode 100644 index 000000000..6f6daf94f --- /dev/null +++ b/test/command/8789.md @@ -0,0 +1,42 @@ +# `\multicolumn` with column-type `p` + +``` +% pandoc --from=latex --to=html +\begin{tabular}{rrll} + \toprule + \textbf{First} & \textbf{Second} & \textbf{Third} & \textbf{Fourth} \\ \toprule + 160 & 1 & test & test \\\midrule + 160 & 2 & \multicolumn{2}{p{12cm}}{\textit{This is a test:} + \begin{equation*} + a^2+b^2 = c^2 + \end{equation*} + }\\ +\bottomrule +\end{tabular} +^D + + + + + + + + + + + + + + + + + + + + + + +
FirstSecondThirdFourth
1601testtest
1602This is a test: a2 + b2 = c2
+ +```