aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMichael Stahl <[email protected]>2023-05-01 14:21:16 +0200
committerJohn MacFarlane <[email protected]>2023-05-01 20:55:37 -0700
commit737446f33d9d8383bdd95d218f77391e0fc08a13 (patch)
tree5d42571a8452a0ea77fb77db12d87fc8220b43b1 /src
parent2881c1274018a31e78ccba647cae4c2764fb5dad (diff)
Writers.OpenDocument: handle row header column cells as header cells
The previous commit prevented header column cells from being dropped on the floor, this one changes the paragraph style to "Table_20_Heading". Note that for the test input, the result is not correct: the AnnotatedTable type cannot represent the HTML input properly, as it only has a concept of header rows and header columns, but HTML can have an individual cell that is a header (not 100% sure but they way i read https://html.spec.whatwg.org/#header-and-data-cell-semantics the <th> cell here is both a row header cell and a column header cell while the other cells in the row and column are not header cells), and header cells may even appear "in the middle" of a table (see example in https://html.spec.whatwg.org/#the-th-element). So while this appears like it's the right thing to do for Writer.OpenDocument, it's not clear if this is going to make things better or worse overall. Fixes: #8764
Diffstat (limited to 'src')
-rw-r--r--src/Text/Pandoc/Writers/OpenDocument.hs16
1 files changed, 9 insertions, 7 deletions
diff --git a/src/Text/Pandoc/Writers/OpenDocument.hs b/src/Text/Pandoc/Writers/OpenDocument.hs
index fa2750b90..feea97d8e 100644
--- a/src/Text/Pandoc/Writers/OpenDocument.hs
+++ b/src/Text/Pandoc/Writers/OpenDocument.hs
@@ -442,7 +442,7 @@ blockToOpenDocument o = \case
then numberedTableCaption ident
else unNumberedCaption "TableCaption"
th <- colHeadsToOpenDocument o (map fst paraHStyles) thead
- tr <- mapM (tableBodyToOpenDocument o (map fst paraStyles)) tbodies
+ tr <- mapM (tableBodyToOpenDocument o (map fst paraHStyles) (map fst paraStyles)) tbodies
let tableDoc = inTags True "table:table" [
("table:name" , name)
, ("table:style-name", name)
@@ -506,19 +506,21 @@ colHeadsToOpenDocument o ns (Ann.TableHead _ hs) =
vcat <$> mapM (tableItemToOpenDocument o "TableHeaderRowCell") (zip ns c)
tableBodyToOpenDocument:: PandocMonad m
- => WriterOptions -> [Text] -> Ann.TableBody
+ => WriterOptions -> [Text] -> [Text] -> Ann.TableBody
-> OD m (Doc Text)
-tableBodyToOpenDocument o ns tb =
+tableBodyToOpenDocument o headns bodyns tb =
let (Ann.TableBody _ _ _ r) = tb
- in vcat <$> mapM (tableRowToOpenDocument o ns) r
+ in vcat <$> mapM (tableRowToOpenDocument o headns bodyns) r
tableRowToOpenDocument :: PandocMonad m
- => WriterOptions -> [Text] -> Ann.BodyRow
+ => WriterOptions -> [Text] -> [Text] -> Ann.BodyRow
-> OD m (Doc Text)
-tableRowToOpenDocument o ns r =
+
+tableRowToOpenDocument o headns bodyns r =
let (Ann.BodyRow _ _ rowheaders cs) = r
in inTagsIndented "table:table-row" . vcat <$>
- mapM (tableItemToOpenDocument o "TableRowCell") (zip ns (rowheaders ++ cs))
+ mapM (tableItemToOpenDocument o "TableRowCell")
+ ((zip headns rowheaders) ++ (zip (drop (length rowheaders) bodyns) cs))
colspanAttrib :: ColSpan -> [(Text, Text)]
colspanAttrib cs =