mirror of
https://github.com/jgm/pandoc.git
synced 2026-08-26 02:06:32 +00:00
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.)
This commit is contained in:
@@ -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 []
|
||||
Nothing -> return $ replicate width mempty
|
||||
|
||||
cells <- mapM rowToBlocksList rows
|
||||
|
||||
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
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
[Table [] [AlignDefault,AlignDefault,AlignDefault] [0.0,0.0,0.0]
|
||||
[]
|
||||
[[]
|
||||
,[]
|
||||
,[]]
|
||||
[[[Plain [Str "One"]]
|
||||
,[Plain [Str "Row"]]
|
||||
,[Plain [Str "Table"]]]]]
|
||||
|
||||
@@ -17,13 +17,15 @@
|
||||
,[Plain [Str "High"]]
|
||||
,[Plain [Str "Tacky",Space,Str "uniform"]]]]
|
||||
,Table [] [AlignDefault,AlignDefault] [0.0,0.0]
|
||||
[]
|
||||
[[]
|
||||
,[]]
|
||||
[[[Plain [Str "Sinple"]]
|
||||
,[Plain [Str "Table"]]]
|
||||
,[[Plain [Str "Without"]]
|
||||
,[Plain [Str "Header"]]]]
|
||||
,Table [] [AlignDefault,AlignDefault] [0.0,0.0]
|
||||
[]
|
||||
[[]
|
||||
,[]]
|
||||
[[[Para [Str "Simple"]
|
||||
,Para [Str "Multiparagraph"]]
|
||||
,[Para [Str "Table"]
|
||||
|
||||
Reference in New Issue
Block a user