git.iko.soy/typeable/pandoc
on master help sign in
Docx reader: Empty header should be list of lists.
60004cdJesse Rosenthal
src/Text/Pandoc/Readers/Docx.hs+11−9
@@ -571,23 +571,25 @@ bodyPartToBlocks (Tbl cap _ look (r:rs)) = do
571 True | null rs -> (Nothing, [r])
571 True | null rs -> (Nothing, [r])
572 | otherwise -> (Just r, rs)
572 | otherwise -> (Just r, rs)
573 False -> (Nothing, r:rs)
573 False -> (Nothing, r:rs)
574+
575+ cells <- mapM rowToBlocksList rows
576+
577+ let width = case cells of
578+ r':_ -> length r'
579+ -- shouldn't happen
580+ [] -> 0
581+
574 hdrCells <- case hdr of
582 hdrCells <- case hdr of
575 Just r' -> rowToBlocksList r'
583 Just r' -> rowToBlocksList r'
576− Nothing -> return []
584+ Nothing -> return $ replicate width mempty
577−
578− cells <- mapM rowToBlocksList rows
579
585
580− let size = case null hdrCells of
581− True -> length $ head cells
582− False -> length $ hdrCells
583− --
584 -- The two following variables (horizontal column alignment and
586 -- The two following variables (horizontal column alignment and
585 -- relative column widths) go to the default at the
587 -- relative column widths) go to the default at the
586 -- moment. Width information is in the TblGrid field of the Tbl,
588 -- moment. Width information is in the TblGrid field of the Tbl,
587 -- so should be possible. Alignment might be more difficult,
589 -- so should be possible. Alignment might be more difficult,
588 -- since there doesn't seem to be a column entity in docx.
590 -- since there doesn't seem to be a column entity in docx.
589− alignments = replicate size AlignDefault
591+ let alignments = replicate width AlignDefault
590− widths = replicate size 0 :: [Double]
592+ widths = replicate width 0 :: [Double]
591
593
592 return $ table caption (zip alignments widths) hdrCells cells
594 return $ table caption (zip alignments widths) hdrCells cells
593bodyPartToBlocks (OMathPara e) = do
595bodyPartToBlocks (OMathPara e) = do
tests/docx/table_one_row.native+3−1
@@ -1,5 +1,7 @@
1[Table [] [AlignDefault,AlignDefault,AlignDefault] [0.0,0.0,0.0]
1[Table [] [AlignDefault,AlignDefault,AlignDefault] [0.0,0.0,0.0]
2− []
2+ [[]
3+ ,[]
4+ ,[]]
3 [[[Plain [Str "One"]]
5 [[[Plain [Str "One"]]
4 ,[Plain [Str "Row"]]
6 ,[Plain [Str "Row"]]
5 ,[Plain [Str "Table"]]]]]
7 ,[Plain [Str "Table"]]]]]
tests/docx/tables.native+4−2
@@ -17,13 +17,15 @@
17 ,[Plain [Str "High"]]
17 ,[Plain [Str "High"]]
18 ,[Plain [Str "Tacky",Space,Str "uniform"]]]]
18 ,[Plain [Str "Tacky",Space,Str "uniform"]]]]
19,Table [] [AlignDefault,AlignDefault] [0.0,0.0]
19,Table [] [AlignDefault,AlignDefault] [0.0,0.0]
20− []
20+ [[]
21+ ,[]]
21 [[[Plain [Str "Sinple"]]
22 [[[Plain [Str "Sinple"]]
22 ,[Plain [Str "Table"]]]
23 ,[Plain [Str "Table"]]]
23 ,[[Plain [Str "Without"]]
24 ,[[Plain [Str "Without"]]
24 ,[Plain [Str "Header"]]]]
25 ,[Plain [Str "Header"]]]]
25,Table [] [AlignDefault,AlignDefault] [0.0,0.0]
26,Table [] [AlignDefault,AlignDefault] [0.0,0.0]
26− []
27+ [[]
28+ ,[]]
27 [[[Para [Str "Simple"]
29 [[[Para [Str "Simple"]
28 ,Para [Str "Multiparagraph"]]
30 ,Para [Str "Multiparagraph"]]
29 ,[Para [Str "Table"]
31 ,[Para [Str "Table"]