aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJohn MacFarlane <[email protected]>2025-10-15 23:23:45 +0200
committerJohn MacFarlane <[email protected]>2025-10-15 23:33:04 +0200
commitd4dd5e9ab945fca7b3e6bcc97993381a12eb39ab (patch)
tree4d7d962badf5457f0685c3e17c21ed33132cbfff /src
parent80ccc78a522845e5c35c6f65845a4315ba699924 (diff)
Docx writer: properly handle nested comment spans.
Patch credit: @mmourino. Closes #8189. Closes #6959.
Diffstat (limited to 'src')
-rw-r--r--src/Text/Pandoc/Writers/Docx/OpenXML.hs19
1 files changed, 11 insertions, 8 deletions
diff --git a/src/Text/Pandoc/Writers/Docx/OpenXML.hs b/src/Text/Pandoc/Writers/Docx/OpenXML.hs
index c9c1bc80f..f687a3493 100644
--- a/src/Text/Pandoc/Writers/Docx/OpenXML.hs
+++ b/src/Text/Pandoc/Writers/Docx/OpenXML.hs
@@ -773,17 +773,20 @@ inlineToOpenXML' _ (Span (ident,["comment-start"],kvs) ils) = do
kvs' = filter (("id" /=) . fst) kvs
modify $ \st -> st{ stComments = (("id",ident'):kvs', ils) : stComments st }
return [ Elem $ mknode "w:commentRangeStart" [("w:id", ident')] () ]
-inlineToOpenXML' _ (Span (ident,["comment-end"],kvs) _) =
+inlineToOpenXML' opts (Span (ident,["comment-end"],kvs) content) = do
-- prefer the "id" in kvs, since that is the one produced by the docx
-- reader.
let ident' = fromMaybe ident (lookup "id" kvs)
- in return . map Elem $
- [ mknode "w:commentRangeEnd" [("w:id", ident')] ()
- , mknode "w:r" []
- [ mknode "w:rPr" []
- [ mknode "w:rStyle" [("w:val", "CommentReference")] () ]
- , mknode "w:commentReference" [("w:id", ident')] () ]
- ]
+ -- process nested content: see #8189
+ nestedContent <- inlinesToOpenXML opts content
+ let thisCommentEnd =
+ [ mknode "w:commentRangeEnd" [("w:id", ident')] ()
+ , mknode "w:r" []
+ [ mknode "w:rPr" []
+ [ mknode "w:rStyle" [("w:val", "CommentReference")] () ]
+ , mknode "w:commentReference" [("w:id", ident')] () ]
+ ]
+ return $ map Elem thisCommentEnd ++ nestedContent
inlineToOpenXML' opts (Span (ident,classes,kvs) ils) = do
stylemod <- case lookup dynamicStyleKey kvs of
Just (fromString . T.unpack -> sty) -> do