aboutsummaryrefslogtreecommitdiff
path: root/src/Text
diff options
context:
space:
mode:
authorJohn MacFarlane <jgm@berkeley.edu>2020-08-24 09:31:39 -0700
committerJohn MacFarlane <jgm@berkeley.edu>2020-08-24 09:31:39 -0700
commit93e3d463fdce74a2f5399a360e4da552ec2fa039 (patch)
tree43c0ec478542ae7a6a2f680db19abfdc6b25135e /src/Text
parent49e810b4ed3642cf549622046bd7f2b98c700894 (diff)
downloadpandoc-93e3d463fdce74a2f5399a360e4da552ec2fa039.tar.gz
Docx writer: separate adjacent tables.
Word combines adjacent tables, so to prevent this we insert an empty paragraph between two adjacent tables. Closes #4315.
Diffstat (limited to 'src/Text')
-rw-r--r--src/Text/Pandoc/Writers/Docx.hs10
1 files changed, 9 insertions, 1 deletions
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") "<w:p />" : separateTables (y:zs)
+separateTables (x:xs) = x : separateTables xs
pStyleM :: (PandocMonad m) => ParaStyleName -> WS m XML.Element
pStyleM styleName = do