git.iko.soy/typeable/pandoc
on master help sign in
Docx writer: autoset table width if no column has an explicit width.
commit0921b82d98b6ec7fa80ffd522c129b3828b9c00b authorAlbert Krewinkel <albert@zeitkraut.de> dateMon 26 Apr 2021, 18:07 (6 years ago) parentd0d8bb9
4 files changed+11−7
src/Text/Pandoc/Writers/Docx/Table.hs+11−7 test/docx/golden/table_one_row.docx test/docx/golden/table_with_list_cell.docx test/docx/golden/tables.docx
src/Text/Pandoc/Writers/Docx/Table.hs+11−7
@@ -1,7 +1,8 @@
1+{-# LANGUAGE LambdaCase #-}
12{-# LANGUAGE OverloadedStrings #-}
23{-# LANGUAGE ScopedTypeVariables #-}
34{- |
4−Module : Text.Pandoc.Writers.Docx
5+Module : Text.Pandoc.Writers.Docx.Table
56Copyright : Copyright (C) 2012-2021 John MacFarlane
67License : GNU GPL, version 2 or above
78Maintainer : John MacFarlane <jgm@berkeley.edu>
@@ -87,7 +88,10 @@ tableToOpenXML blocksToOpenXML blkCapt specs thead tbody tfoot = do
8788 mknode "w:tbl" []
8889 ( mknode "w:tblPr" []
8990 ( mknode "w:tblStyle" [("w:val","Table")] () :
90− mknode "w:tblW" [("w:type", "pct"), ("w:w", tshow rowwidth)] () :
91+ mknode "w:tblW" (if all (== 0) widths
92+ then [("w:type", "auto"), ("w:w", "0")]
93+ else [("w:type", "pct"), ("w:w", tshow rowwidth)])
94+ () :
9195 mknode "w:tblLook" [("w:firstRow",if hasHeader then "1" else "0")
9296 ,("w:lastRow","0")
9397 ,("w:firstColumn","0")
@@ -107,8 +111,8 @@ tableToOpenXML blocksToOpenXML blkCapt specs thead tbody tfoot = do
107111 )]
108112
109113alignmentToString :: Alignment -> Text
110−alignmentToString alignment = case alignment of
111− AlignLeft -> "left"
112− AlignRight -> "right"
113− AlignCenter -> "center"
114− AlignDefault -> "left"
114+alignmentToString = \case
115+ AlignLeft -> "left"
116+ AlignRight -> "right"
117+ AlignCenter -> "center"
118+ AlignDefault -> "left"
test/docx/golden/table_one_row.docx

Binary file not shown.

test/docx/golden/table_with_list_cell.docx

Binary file not shown.

test/docx/golden/tables.docx

Binary file not shown.