aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJohn MacFarlane <[email protected]>2025-03-23 16:14:02 -0700
committerJohn MacFarlane <[email protected]>2025-03-23 16:14:54 -0700
commit15052fd2fd92e3199ba33bdc0b60bfa624eba892 (patch)
tree094071e29a9dca89628ca62360fb69758b8b09ba /src
parente3f31588a38f65d72571d6d71c3d524168ef4028 (diff)
Docx writer: ensure that figures and tables with custom styles...
...are not dropped. Closes #10705.
Diffstat (limited to 'src')
-rw-r--r--src/Text/Pandoc/Readers/Docx.hs19
1 files changed, 11 insertions, 8 deletions
diff --git a/src/Text/Pandoc/Readers/Docx.hs b/src/Text/Pandoc/Readers/Docx.hs
index 74c7c9445..8e63b1be1 100644
--- a/src/Text/Pandoc/Readers/Docx.hs
+++ b/src/Text/Pandoc/Readers/Docx.hs
@@ -800,14 +800,17 @@ bodyPartToBlocks (Captioned parstyle parparts bpart) = do
bs <- bodyPartToBlocks bpart
captContents <- bodyPartToBlocks (Paragraph parstyle parparts)
let capt = Caption Nothing (toList captContents)
- case toList bs of
- [Table attr _cap colspecs thead tbodies tfoot]
- -> pure $ singleton $ Table attr capt colspecs thead tbodies tfoot
- [Figure attr _cap blks]
- -> pure $ singleton $ Figure attr capt blks
- [Para im@[Image{}]]
- -> pure $ singleton $ Figure nullAttr capt [Plain im]
- _ -> pure captContents
+ let toCaptioned attr' bls = case bls of
+ [Table attr _cap colspecs thead tbodies tfoot]
+ -> singleton $ Table (attr <> attr') capt colspecs thead tbodies tfoot
+ [Figure attr _cap blks]
+ -> singleton $ Figure (attr <> attr') capt blks
+ [Para im@[Image{}]]
+ -> singleton $ Figure attr' capt [Plain im]
+ [Div attr bls']
+ -> toCaptioned (attr <> attr') bls'
+ _ -> captContents
+ pure $ toCaptioned nullAttr (toList bs)
bodyPartToBlocks (Tbl _ _ _ _ []) =
return mempty
bodyPartToBlocks (Tbl mbsty cap grid look parts) = do