aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAlbert Krewinkel <albert@zeitkraut.de>2021-04-26 18:07:01 +0200
committerAlbert Krewinkel <albert@zeitkraut.de>2021-04-27 13:27:20 +0200
commit0921b82d98b6ec7fa80ffd522c129b3828b9c00b (patch)
treeff548699d3d6a34fb4fa6356e0239edfddbfa81e /src
parentd0d8bb981861a5c076d1c525240791f631140f80 (diff)
downloadpandoc-0921b82d98b6ec7fa80ffd522c129b3828b9c00b.tar.gz
Docx writer: autoset table width if no column has an explicit width.
Diffstat (limited to 'src')
-rw-r--r--src/Text/Pandoc/Writers/Docx/Table.hs18
1 files changed, 11 insertions, 7 deletions
diff --git a/src/Text/Pandoc/Writers/Docx/Table.hs b/src/Text/Pandoc/Writers/Docx/Table.hs
index a6b137fc4..349f3a4ce 100644
--- a/src/Text/Pandoc/Writers/Docx/Table.hs
+++ b/src/Text/Pandoc/Writers/Docx/Table.hs
@@ -1,7 +1,8 @@
+{-# LANGUAGE LambdaCase #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE ScopedTypeVariables #-}
{- |
-Module : Text.Pandoc.Writers.Docx
+Module : Text.Pandoc.Writers.Docx.Table
Copyright : Copyright (C) 2012-2021 John MacFarlane
License : GNU GPL, version 2 or above
Maintainer : John MacFarlane <jgm@berkeley.edu>
@@ -87,7 +88,10 @@ tableToOpenXML blocksToOpenXML blkCapt specs thead tbody tfoot = do
mknode "w:tbl" []
( mknode "w:tblPr" []
( mknode "w:tblStyle" [("w:val","Table")] () :
- mknode "w:tblW" [("w:type", "pct"), ("w:w", tshow rowwidth)] () :
+ mknode "w:tblW" (if all (== 0) widths
+ then [("w:type", "auto"), ("w:w", "0")]
+ else [("w:type", "pct"), ("w:w", tshow rowwidth)])
+ () :
mknode "w:tblLook" [("w:firstRow",if hasHeader then "1" else "0")
,("w:lastRow","0")
,("w:firstColumn","0")
@@ -107,8 +111,8 @@ tableToOpenXML blocksToOpenXML blkCapt specs thead tbody tfoot = do
)]
alignmentToString :: Alignment -> Text
-alignmentToString alignment = case alignment of
- AlignLeft -> "left"
- AlignRight -> "right"
- AlignCenter -> "center"
- AlignDefault -> "left"
+alignmentToString = \case
+ AlignLeft -> "left"
+ AlignRight -> "right"
+ AlignCenter -> "center"
+ AlignDefault -> "left"