From 9f3c34841b4751289cb3ecea222b99d07dbd986d Mon Sep 17 00:00:00 2001 From: Christoffer Ackelman Date: Fri, 15 Aug 2014 13:52:30 +0200 Subject: Include row width in table rows. Added a property to all table rows where the sum of column widths is specified in pct (fraction of 5000). --- src/Text/Pandoc/Writers/Docx.hs | 3 +++ 1 file changed, 3 insertions(+) (limited to 'src/Text') diff --git a/src/Text/Pandoc/Writers/Docx.hs b/src/Text/Pandoc/Writers/Docx.hs index 38031b7dc..b01a1567e 100644 --- a/src/Text/Pandoc/Writers/Docx.hs +++ b/src/Text/Pandoc/Writers/Docx.hs @@ -596,12 +596,15 @@ blockToOpenXML opts (Table caption aligns widths headers rows) = do else contents let mkrow border cells = mknode "w:tr" [] $ map (mkcell border) cells let textwidth = 7920 -- 5.5 in in twips, 1/20 pt + let fullrow = 5000 + let rowwidth = sum $ map (fullrow *) widths let mkgridcol w = mknode "w:gridCol" [("w:w", show $ (floor (textwidth * w) :: Integer))] () return $ [ mknode "w:tbl" [] ( mknode "w:tblPr" [] ( [ mknode "w:tblStyle" [("w:val","TableNormal")] () ] ++ + [ mknode "w:tblW" [("w:type", "pct"), ("w:w", (show rowwidth))] () ] ++ [ mknode "w:tblCaption" [("w:val", captionStr)] () | not (null caption) ] ) : mknode "w:tblGrid" [] -- cgit v1.2.3 From 753e47194c9f04f72532139e6bf2e9122a1356c3 Mon Sep 17 00:00:00 2001 From: Viktor Kronvall Date: Sun, 17 Aug 2014 03:24:22 +0200 Subject: Simplify row width calculation. --- src/Text/Pandoc/Writers/Docx.hs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/Text') diff --git a/src/Text/Pandoc/Writers/Docx.hs b/src/Text/Pandoc/Writers/Docx.hs index b01a1567e..010a6e3ff 100644 --- a/src/Text/Pandoc/Writers/Docx.hs +++ b/src/Text/Pandoc/Writers/Docx.hs @@ -596,8 +596,8 @@ blockToOpenXML opts (Table caption aligns widths headers rows) = do else contents let mkrow border cells = mknode "w:tr" [] $ map (mkcell border) cells let textwidth = 7920 -- 5.5 in in twips, 1/20 pt - let fullrow = 5000 - let rowwidth = sum $ map (fullrow *) widths + let fullrow = 5000 -- 100% specified in pct + let rowwidth = fullrow * sum widths let mkgridcol w = mknode "w:gridCol" [("w:w", show $ (floor (textwidth * w) :: Integer))] () return $ -- cgit v1.2.3