summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJohn MacFarlane <jgm@berkeley.edu>2023-08-05 11:47:08 -0700
committerJohn MacFarlane <jgm@berkeley.edu>2023-08-05 11:48:29 -0700
commit1d62883e144ca3792638061c5659230712c48a61 (patch)
treeb5a8f393ea58b5287cfb5378b509037beeb7aa5d /src
parent0a1ea3d8ca76540ff6bf619f84d2eabfad1ef70f (diff)
HTML reader: require unanimity for RowHeadColumns.
Previously we used the max. #8634 switched to the min, but this had bad results. This commit sets the RowHeadColumns to the consensus value from all rows, or 0 if there is no consensus. See #8984.
Diffstat (limited to 'src')
-rw-r--r--src/Text/Pandoc/Readers/HTML/Table.hs7
1 files changed, 6 insertions, 1 deletions
diff --git a/src/Text/Pandoc/Readers/HTML/Table.hs b/src/Text/Pandoc/Readers/HTML/Table.hs
index 99a090f16..eb60cdb07 100644
--- a/src/Text/Pandoc/Readers/HTML/Table.hs
+++ b/src/Text/Pandoc/Readers/HTML/Table.hs
@@ -193,7 +193,12 @@ pTableBody block = try $ do
optional $ pSatisfy (matchTagClose "tbody")
guard $ isJust mbattribs || not (null bodyheads && null rows)
let attribs = fromMaybe [] mbattribs
- return $ TableBody (toAttr attribs) (foldr max 0 rowheads) bodyheads rows
+ -- we only set row head columns if all rows agree;
+ -- if some rows have headings but others not, we use 0; see #8984, #8634:
+ let rowHeadCols = case rowheads of
+ (x:xs) | all (== x) xs -> x
+ _ -> 0
+ return $ TableBody (toAttr attribs) rowHeadCols bodyheads rows
where
getAttribs (TagOpen _ attribs) = attribs
getAttribs _ = []