Docx writer: fix nested tables with captions.
Previously we got unreadable content, because docx seems to want a `<w:p>` element (even an empty one) at the end of every table cell. Closes #6983.
This commit is contained in:
parent
a7a162ea55
commit
55f9b59af1
1 changed files with 6 additions and 4 deletions
|
@ -1011,12 +1011,14 @@ blockToOpenXML' opts (Table _ blkCapt specs thead tbody tfoot) = do
|
|||
$ blockToOpenXML opts (Para caption)
|
||||
let alignmentFor al = mknode "w:jc" [("w:val",alignmentToString al)] ()
|
||||
-- Table cells require a <w:p> element, even an empty one!
|
||||
-- Not in the spec but in Word 2007, 2010. See #4953.
|
||||
-- Not in the spec but in Word 2007, 2010. See #4953. And
|
||||
-- apparently the last element must be a <w:p>, see #6983.
|
||||
let cellToOpenXML (al, cell) = do
|
||||
es <- withParaProp (alignmentFor al) $ blocksToOpenXML opts cell
|
||||
return $ if any (\e -> qName (elName e) == "p") (onlyElems es)
|
||||
then es
|
||||
else es ++ [Elem $ mknode "w:p" [] ()]
|
||||
return $
|
||||
case reverse (onlyElems es) of
|
||||
e:_ | qName (elName e) == "p" -> es
|
||||
_ -> es ++ [Elem $ mknode "w:p" [] ()]
|
||||
headers' <- mapM cellToOpenXML $ zip aligns headers
|
||||
rows' <- mapM (mapM cellToOpenXML . zip aligns) rows
|
||||
let borderProps = Elem $ mknode "w:tcPr" []
|
||||
|
|
Loading…
Add table
Reference in a new issue