From 899feec4d341cf464e9fc6d72e40477ac7fbac15 Mon Sep 17 00:00:00 2001
From: John MacFarlane <jgm@berkeley.edu>
Date: Fri, 11 Feb 2022 09:42:24 -0800
Subject: [PATCH] RST reader: fix treatment of headerless simple tables.

We were producing a header with blank cells rather than no
header.  Closes #7902.
---
 src/Text/Pandoc/Readers/RST.hs |  2 +-
 test/rst-reader.native         | 10 +---------
 test/tables-rstsubset.native   | 11 +----------
 3 files changed, 3 insertions(+), 20 deletions(-)

diff --git a/src/Text/Pandoc/Readers/RST.hs b/src/Text/Pandoc/Readers/RST.hs
index 4d037e6ed..89479a541 100644
--- a/src/Text/Pandoc/Readers/RST.hs
+++ b/src/Text/Pandoc/Readers/RST.hs
@@ -1304,7 +1304,7 @@ simpleTableHeader headless = try $ do
   let indices  = scanl (+) 0 lines'
   let aligns   = replicate (length lines') AlignDefault
   let rawHeads = if headless
-                    then replicate (length dashes) ""
+                    then []
                     else simpleTableSplitLine indices rawContent
   heads <- mapM ( parseFromString' (mconcat <$> many plain) . trim) rawHeads
   return (heads, aligns, indices)
diff --git a/test/rst-reader.native b/test/rst-reader.native
index d3e7f6caa..f5c60cd4f 100644
--- a/test/rst-reader.native
+++ b/test/rst-reader.native
@@ -1124,15 +1124,7 @@ Pandoc
       , ( AlignDefault , ColWidthDefault )
       , ( AlignDefault , ColWidthDefault )
       ]
-      (TableHead
-         ( "" , [] , [] )
-         [ Row
-             ( "" , [] , [] )
-             [ Cell ( "" , [] , [] ) AlignDefault (RowSpan 1) (ColSpan 1) []
-             , Cell ( "" , [] , [] ) AlignDefault (RowSpan 1) (ColSpan 1) []
-             , Cell ( "" , [] , [] ) AlignDefault (RowSpan 1) (ColSpan 1) []
-             ]
-         ])
+      (TableHead ( "" , [] , [] ) [])
       [ TableBody
           ( "" , [] , [] )
           (RowHeadColumns 0)
diff --git a/test/tables-rstsubset.native b/test/tables-rstsubset.native
index ba3fb211a..d9fd4342a 100644
--- a/test/tables-rstsubset.native
+++ b/test/tables-rstsubset.native
@@ -755,16 +755,7 @@
     , ( AlignDefault , ColWidthDefault )
     , ( AlignDefault , ColWidthDefault )
     ]
-    (TableHead
-       ( "" , [] , [] )
-       [ Row
-           ( "" , [] , [] )
-           [ Cell ( "" , [] , [] ) AlignDefault (RowSpan 1) (ColSpan 1) []
-           , Cell ( "" , [] , [] ) AlignDefault (RowSpan 1) (ColSpan 1) []
-           , Cell ( "" , [] , [] ) AlignDefault (RowSpan 1) (ColSpan 1) []
-           , Cell ( "" , [] , [] ) AlignDefault (RowSpan 1) (ColSpan 1) []
-           ]
-       ])
+    (TableHead ( "" , [] , [] ) [])
     [ TableBody
         ( "" , [] , [] )
         (RowHeadColumns 0)