aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorTuong Nguyen Manh <[email protected]>2025-08-09 13:48:32 +0200
committerAlbert Krewinkel <[email protected]>2025-08-10 08:20:49 +0200
commit816ca8480dd0887f39294f91a38e66bda33bbd2d (patch)
tree8cc7f87f1f5b937141eba4cbdd56b49ba7cd7e1b /src
parent282fa55421b76f93a98682088807d79267d3bb38 (diff)
ODT Reader: Add table-header-rows
Diffstat (limited to 'src')
-rw-r--r--src/Text/Pandoc/Readers/ODT/ContentReader.hs27
1 files changed, 19 insertions, 8 deletions
diff --git a/src/Text/Pandoc/Readers/ODT/ContentReader.hs b/src/Text/Pandoc/Readers/ODT/ContentReader.hs
index 2d4b98949..b9778bdd3 100644
--- a/src/Text/Pandoc/Readers/ODT/ContentReader.hs
+++ b/src/Text/Pandoc/Readers/ODT/ContentReader.hs
@@ -795,15 +795,26 @@ read_citation = matchingElement NsText "bibliography-mark"
read_table :: BlockMatcher
read_table = matchingElement NsTable "table"
$ liftA simpleTable'
- $ matchChildContent' [ read_table_row
- ]
+ $ (matchChildContent' [read_table_header]) &&&
+ (matchChildContent' [read_table_row])
+
+-- | A simple table without a caption.
+simpleTable' :: ([[Blocks]], [[Blocks]]) -> Blocks
+simpleTable' (headers, rows) =
+ table emptyCaption (replicate numcols defaults) th [tb] tf
+ where
+ defaults = (AlignDefault, ColWidthDefault)
+ numcols = maximum $ map length $ headers ++ rows
+ toRow = Row nullAttr . map simpleCell
+ th = TableHead nullAttr $ map toRow headers
+ tb = TableBody nullAttr 0 [] $ map toRow rows
+ tf = TableFoot nullAttr []
--- | A simple table without a caption or headers
--- | Infers the number of headers from rows
-simpleTable' :: [[Blocks]] -> Blocks
-simpleTable' [] = simpleTable [] []
-simpleTable' (x : rest) = simpleTable (fmap (const defaults) x) (x : rest)
- where defaults = fromList []
+--
+read_table_header :: ElementMatcher [[Blocks]]
+read_table_header = matchingElement NsTable "table-header-rows"
+ $ matchChildContent' [ read_table_row
+ ]
--
read_table_row :: ElementMatcher [[Blocks]]