diff options
| author | John MacFarlane <[email protected]> | 2026-01-06 11:52:56 +0100 |
|---|---|---|
| committer | John MacFarlane <[email protected]> | 2026-01-07 11:21:50 +0100 |
| commit | b026624ed7399e62137233dadbacfb4d59c28f3b (patch) | |
| tree | 5229437e6842e85082a2fdbc72b29ee393a2cd36 | |
| parent | 7dafc1a8e50974f569d8b98ebef5e9adaa53a670 (diff) | |
Docx reader: handle tables without tblGrid.
Closes #11380.
| -rw-r--r-- | src/Text/Pandoc/Readers/Docx.hs | 4 | ||||
| -rw-r--r-- | src/Text/Pandoc/Readers/Docx/Parse.hs | 8 |
2 files changed, 10 insertions, 2 deletions
diff --git a/src/Text/Pandoc/Readers/Docx.hs b/src/Text/Pandoc/Readers/Docx.hs index 8ec14c040..da0cca1dc 100644 --- a/src/Text/Pandoc/Readers/Docx.hs +++ b/src/Text/Pandoc/Readers/Docx.hs @@ -837,7 +837,9 @@ bodyPartToBlocks (Tbl mbsty cap grid look parts) = do alignments = case rows of [] -> replicate width Pandoc.AlignDefault Docx.Row _ cs : _ -> concatMap getAlignment cs - widths = map ColWidth grid + widths = map (\n -> if n == 0 + then ColWidthDefault + else ColWidth n) grid extStylesEnabled <- asks (isEnabled Ext_styles . docxOptions) let attr = case mbsty of diff --git a/src/Text/Pandoc/Readers/Docx/Parse.hs b/src/Text/Pandoc/Readers/Docx/Parse.hs index c2ad9e837..68069d7d6 100644 --- a/src/Text/Pandoc/Readers/Docx/Parse.hs +++ b/src/Text/Pandoc/Readers/Docx/Parse.hs @@ -875,9 +875,15 @@ elemToBodyPart ns element Just l -> elemToTblLook ns l Nothing -> return defaultTblLook - grid <- grid' + grid'' <- grid' tblLook <- tblLook' rows <- mapD (elemToRow ns) (elChildren element) + let grid = if null grid'' + then let numcols = case rowsToRowspans rows of + (cs@(_:_):_) -> sum (map fst cs) + _ -> 0 + in replicate numcols 0.0 + else grid'' return $ Tbl mbstyle (caption <> description) grid tblLook rows elemToBodyPart _ _ = throwError WrongElem |
