diff options
| author | Tuong Nguyen Manh <[email protected]> | 2025-12-29 01:13:06 +0100 |
|---|---|---|
| committer | GitHub <[email protected]> | 2025-12-28 17:13:06 -0700 |
| commit | 854b7332d9f3044be15344fd57637f15b482f7e9 (patch) | |
| tree | 6983b33c1e1e217b824e91eea08bf62045ff4bb3 /src | |
| parent | d21c17c096778f5892c070633d595627c9c530f2 (diff) | |
ODT reader: Add table row and column spans (#11366)
Parse the number-rows-spanned and number-columns-spanned attributes to
create Cells for the Table.
Diffstat (limited to 'src')
| -rw-r--r-- | src/Text/Pandoc/Readers/ODT/ContentReader.hs | 24 |
1 files changed, 14 insertions, 10 deletions
diff --git a/src/Text/Pandoc/Readers/ODT/ContentReader.hs b/src/Text/Pandoc/Readers/ODT/ContentReader.hs index b9778bdd3..e5f1a4822 100644 --- a/src/Text/Pandoc/Readers/ODT/ContentReader.hs +++ b/src/Text/Pandoc/Readers/ODT/ContentReader.hs @@ -794,42 +794,46 @@ read_citation = matchingElement NsText "bibliography-mark" -- read_table :: BlockMatcher read_table = matchingElement NsTable "table" - $ liftA simpleTable' + $ liftA table' $ (matchChildContent' [read_table_header]) &&& - (matchChildContent' [read_table_row]) + (matchChildContent' [read_table_row]) --- | A simple table without a caption. -simpleTable' :: ([[Blocks]], [[Blocks]]) -> Blocks -simpleTable' (headers, rows) = +-- | A table without a caption. +table' :: ([[Cell]], [[Cell]]) -> Blocks +table' (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 + toRow = Row nullAttr th = TableHead nullAttr $ map toRow headers tb = TableBody nullAttr 0 [] $ map toRow rows tf = TableFoot nullAttr [] -- -read_table_header :: ElementMatcher [[Blocks]] +read_table_header :: ElementMatcher [[Cell]] read_table_header = matchingElement NsTable "table-header-rows" $ matchChildContent' [ read_table_row ] -- -read_table_row :: ElementMatcher [[Blocks]] +read_table_row :: ElementMatcher [[Cell]] read_table_row = matchingElement NsTable "table-row" $ liftA (:[]) $ matchChildContent' [ read_table_cell ] -- -read_table_cell :: ElementMatcher [Blocks] +read_table_cell :: ElementMatcher [Cell] read_table_cell = matchingElement NsTable "table-cell" - $ liftA (compactify.(:[])) + $ liftA3 cell' + (readAttrWithDefault NsTable "number-rows-spanned" 1 >>^ RowSpan) + (readAttrWithDefault NsTable "number-columns-spanned" 1 >>^ ColSpan) $ matchChildContent' [ read_paragraph , read_list ] + where + cell' rowSpan colSpan blocks = map (cell AlignDefault rowSpan colSpan) $ compactify [blocks] ---------------------- -- Frames |
