HTML reader: fix bug in calculation of RowHeadColumns.

We were adding up cells, not colspans.
Note: there may still be incorrect results in the presence of
rowspans.

See https://github.com/jgm/pandoc/issues/8984#issuecomment-1666467926
This commit is contained in:
John MacFarlane
2023-08-05 11:28:03 -07:00
parent d7a7f5ad19
commit 0a1ea3d8ca
+3 -1
View File
@@ -133,7 +133,9 @@ pRow block = try $ do
TagOpen _ attribs <- pSatisfy (matchTagOpen "tr" []) <* skipMany pBlank
cells <- many (pCell block BodyCell <|> pCell block HeaderCell)
TagClose _ <- pSatisfy (matchTagClose "tr")
return ( RowHeadColumns $ length (takeWhile ((== HeaderCell) . fst) cells)
return ( RowHeadColumns $ foldr (\(_, Cell _ _ _ (ColSpan colspan) _) ->
(+ colspan)) 0
(takeWhile ((== HeaderCell) . fst) cells)
, Row (toAttr attribs) $ map snd cells
)