summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn MacFarlane <jgm@berkeley.edu>2024-01-20 10:19:03 -0800
committerJohn MacFarlane <jgm@berkeley.edu>2024-01-20 10:19:32 -0800
commitf43ffabd3c598f7154cd101069e7e77947f5676d (patch)
tree8a0f9977d136e3ff4899074f53dfb3fa0958920f
parentc2f7f5c63fe223f07033cfc686cb258508970301 (diff)
LaTeX writer: create valid table even when table is empty.
Closes #9350.
-rw-r--r--src/Text/Pandoc/Writers/LaTeX/Table.hs14
-rw-r--r--test/command/9350.md12
2 files changed, 20 insertions, 6 deletions
diff --git a/src/Text/Pandoc/Writers/LaTeX/Table.hs b/src/Text/Pandoc/Writers/LaTeX/Table.hs
index 702b22328..4dfe6be62 100644
--- a/src/Text/Pandoc/Writers/LaTeX/Table.hs
+++ b/src/Text/Pandoc/Writers/LaTeX/Table.hs
@@ -137,12 +137,14 @@ colDescriptors isSimpleTable
then replicate (length specs)
(1 / fromIntegral (length specs))
else map toRelWidth widths
- in if defaultWidthsOnly && isSimpleTable
- then hcat $ map (literal . colAlign) aligns
- else (cr <>) . nest 2 . vcat . map literal $
- zipWith (toColDescriptor (length specs))
- aligns
- relativeWidths
+ in if null aligns
+ then "l" -- #9350, table needs at least one column spec
+ else if defaultWidthsOnly && isSimpleTable
+ then hcat $ map (literal . colAlign) aligns
+ else (cr <>) . nest 2 . vcat . map literal $
+ zipWith (toColDescriptor (length specs))
+ aligns
+ relativeWidths
where
toColDescriptor :: Int -> Alignment -> Double -> Text
toColDescriptor numcols align width =
diff --git a/test/command/9350.md b/test/command/9350.md
new file mode 100644
index 000000000..d641f8b76
--- /dev/null
+++ b/test/command/9350.md
@@ -0,0 +1,12 @@
+```
+% pandoc -f html -t latex
+<table><tbody><tr></tr></tbody></table>
+^D
+\begin{longtable}[]{@{}l@{}}
+\toprule\noalign{}
+\endhead
+\bottomrule\noalign{}
+\endlastfoot
+ \\
+\end{longtable}
+```