From 93e3d463fdce74a2f5399a360e4da552ec2fa039 Mon Sep 17 00:00:00 2001 From: John MacFarlane Date: Mon, 24 Aug 2020 09:31:39 -0700 Subject: Docx writer: separate adjacent tables. Word combines adjacent tables, so to prevent this we insert an empty paragraph between two adjacent tables. Closes #4315. --- src/Text/Pandoc/Writers/Docx.hs | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'src/Text/Pandoc') diff --git a/src/Text/Pandoc/Writers/Docx.hs b/src/Text/Pandoc/Writers/Docx.hs index f448c4ce2..e738008ee 100644 --- a/src/Text/Pandoc/Writers/Docx.hs +++ b/src/Text/Pandoc/Writers/Docx.hs @@ -848,7 +848,15 @@ writeOpenXML opts (Pandoc meta blocks) = do -- | Convert a list of Pandoc blocks to OpenXML. blocksToOpenXML :: (PandocMonad m) => WriterOptions -> [Block] -> WS m [Element] -blocksToOpenXML opts bls = concat `fmap` mapM (blockToOpenXML opts) bls +blocksToOpenXML opts = fmap concat . mapM (blockToOpenXML opts) . separateTables + +-- Word combines adjacent tables unless you put an empty paragraph between +-- them. See #4315. +separateTables :: [Block] -> [Block] +separateTables [] = [] +separateTables (x@Table{}:y@Table{}:zs) = + x : RawBlock (Format "openxml") "" : separateTables (y:zs) +separateTables (x:xs) = x : separateTables xs pStyleM :: (PandocMonad m) => ParaStyleName -> WS m XML.Element pStyleM styleName = do -- cgit v1.2.3