diff options
| author | John MacFarlane <jgm@berkeley.edu> | 2023-12-18 10:18:57 -0800 |
|---|---|---|
| committer | John MacFarlane <jgm@berkeley.edu> | 2023-12-18 10:18:57 -0800 |
| commit | f7e31adc9708760565c4533781f0bf78e7782899 (patch) | |
| tree | 5e0a96a9680e3214e3a10ce5c159713df8d170b2 /src | |
| parent | 9c5e6aeedc8fe8653e9e050d5dfefc969f0d8e8c (diff) | |
Docx writer: fixed validation errors in tables.
Closes #9266.
Diffstat (limited to 'src')
| -rw-r--r-- | src/Text/Pandoc/Writers/Docx.hs | 13 | ||||
| -rw-r--r-- | src/Text/Pandoc/Writers/Docx/Table.hs | 24 |
2 files changed, 18 insertions, 19 deletions
diff --git a/src/Text/Pandoc/Writers/Docx.hs b/src/Text/Pandoc/Writers/Docx.hs index b0d902403..765d95d6c 100644 --- a/src/Text/Pandoc/Writers/Docx.hs +++ b/src/Text/Pandoc/Writers/Docx.hs @@ -1138,18 +1138,17 @@ toFigureTable opts blks = do map blockToCell blks let tbl = mknode "w:tbl" [] ( mknode "w:tblPr" [] - ( mknode "w:tblStyle" [("w:val","FigureTable")] () : - mknode "w:tblW" [ ("w:type", "auto"), ("w:w", "0") ] () : + [ mknode "w:tblStyle" [("w:val","FigureTable")] (), + mknode "w:tblW" [ ("w:type", "auto"), ("w:w", "0") ] (), + mknode "w:jc" [("w:val","center")] (), mknode "w:tblLook" [ ("w:firstRow", "0") , ("w:lastRow", "0") , ("w:firstColumn", "0") , ("w:lastColumn", "0") - ] () : - mknode "w:jc" [("w:val","center")] () : - [] - ) + ] () + ] : mknode "w:tblGrid" [] gridCols - : (maybeToList tblBody) + : maybeToList tblBody ) modify $ \s -> s { stInTable = False } return $ Elem tbl diff --git a/src/Text/Pandoc/Writers/Docx/Table.hs b/src/Text/Pandoc/Writers/Docx/Table.hs index d80426da3..4c6d81be6 100644 --- a/src/Text/Pandoc/Writers/Docx/Table.hs +++ b/src/Text/Pandoc/Writers/Docx/Table.hs @@ -113,20 +113,20 @@ tableToOpenXML opts blocksToOpenXML gridTable = do let hasWidths = not $ all ((== ColWidthDefault) . snd) colspecs let tbl = mknode "w:tbl" [] ( mknode "w:tblPr" [] - ( mknode "w:tblStyle" [("w:val","Table")] () : - mknode "w:tblW" tblWattr () : - mknode "w:tblLook" [("w:firstRow",if hasHeader then "1" else "0") - ,("w:lastRow",if hasFooter then "1" else "0") - ,("w:firstColumn","0") - ,("w:lastColumn","0") - ,("w:noHBand","0") - ,("w:noVBand","0") - ,("w:val", T.pack $ printf "%04x" tblLookVal) - ] () : - mknode "w:jc" [("w:val","start")] () - : [ mknode "w:tblInd" [("w:w", tshow indent),("w:type","dxa")] () + ( [ mknode "w:tblStyle" [("w:val","Table")] (), + mknode "w:tblW" tblWattr (), + mknode "w:jc" [("w:val","start")] () ] ++ + [ mknode "w:tblInd" [("w:w", tshow indent),("w:type","dxa")] () | indent > 0 ] ++ [ mknode "w:tblLayout" [("w:type", "fixed")] () | hasWidths ] ++ + [ mknode "w:tblLook" [("w:firstRow",if hasHeader then "1" else "0") + ,("w:lastRow",if hasFooter then "1" else "0") + ,("w:firstColumn","0") + ,("w:lastColumn","0") + ,("w:noHBand","0") + ,("w:noVBand","0") + ,("w:val", T.pack $ printf "%04x" tblLookVal) + ] () ] ++ [ mknode "w:tblCaption" [("w:val", captionStr)] () | not (T.null captionStr) ] ) |
