aboutsummaryrefslogtreecommitdiff
path: root/src/Text/Pandoc
diff options
context:
space:
mode:
authorJesse Rosenthal <jrosenthal@jhu.edu>2016-12-13 06:58:16 -0500
committerJesse Rosenthal <jrosenthal@jhu.edu>2016-12-13 07:04:40 -0500
commit60004cd518f0fc72d45633dbb552f153bc3bfe96 (patch)
tree5947c32d0a9e081891b55b40ad553ffbdffb1de8 /src/Text/Pandoc
parent7caaa5b2b65a8dd27c2bfceb580c8cdd71f37459 (diff)
downloadpandoc-60004cd518f0fc72d45633dbb552f153bc3bfe96.tar.gz
Docx reader: Empty header should be list of lists.
In the past, the docx reader wrote an empty header as an empty list. It should have the same width as a row (and be filled with empty cells). (Note that I've reordered the code here slightly to get rid of a call to `head`. It wasn't unsafe because it tested for null, but it was a bit of a smell.)
Diffstat (limited to 'src/Text/Pandoc')
-rw-r--r--src/Text/Pandoc/Readers/Docx.hs20
1 files changed, 11 insertions, 9 deletions
diff --git a/src/Text/Pandoc/Readers/Docx.hs b/src/Text/Pandoc/Readers/Docx.hs
index c8a09248a..595c805bf 100644
--- a/src/Text/Pandoc/Readers/Docx.hs
+++ b/src/Text/Pandoc/Readers/Docx.hs
@@ -571,23 +571,25 @@ bodyPartToBlocks (Tbl cap _ look (r:rs)) = do
True | null rs -> (Nothing, [r])
| otherwise -> (Just r, rs)
False -> (Nothing, r:rs)
+
+ cells <- mapM rowToBlocksList rows
+
+ let width = case cells of
+ r':_ -> length r'
+ -- shouldn't happen
+ [] -> 0
+
hdrCells <- case hdr of
Just r' -> rowToBlocksList r'
- Nothing -> return []
-
- cells <- mapM rowToBlocksList rows
+ Nothing -> return $ replicate width mempty
- let size = case null hdrCells of
- True -> length $ head cells
- False -> length $ hdrCells
- --
-- The two following variables (horizontal column alignment and
-- relative column widths) go to the default at the
-- moment. Width information is in the TblGrid field of the Tbl,
-- so should be possible. Alignment might be more difficult,
-- since there doesn't seem to be a column entity in docx.
- alignments = replicate size AlignDefault
- widths = replicate size 0 :: [Double]
+ let alignments = replicate width AlignDefault
+ widths = replicate width 0 :: [Double]
return $ table caption (zip alignments widths) hdrCells cells
bodyPartToBlocks (OMathPara e) = do