From 3c8ca600eff9db0e3f2a5740df85680cc2c8cec3 Mon Sep 17 00:00:00 2001 From: Stephen Reindl <4533301+steven-r@users.noreply.github.com> Date: Fri, 31 Jan 2025 00:23:53 +0100 Subject: [PATCH] DOCX reader: do not issue warning for comments with `+styles` (#10572) Closes #10571. Co-authored-by: Stephen Reindl --- src/Text/Pandoc/Readers/Docx.hs | 7 ++++--- test/Tests/Readers/Docx.hs | 5 +++++ 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/src/Text/Pandoc/Readers/Docx.hs b/src/Text/Pandoc/Readers/Docx.hs index 3222e81b6..cafd4cbe6 100644 --- a/src/Text/Pandoc/Readers/Docx.hs +++ b/src/Text/Pandoc/Readers/Docx.hs @@ -357,9 +357,10 @@ extentToAttr _ = nullAttr blocksToInlinesWarn :: PandocMonad m => T.Text -> Blocks -> DocxContext m Inlines blocksToInlinesWarn cmtId blks = do let paraOrPlain :: Block -> Bool - paraOrPlain (Para _) = True - paraOrPlain (Plain _) = True - paraOrPlain _ = False + paraOrPlain (Para _) = True + paraOrPlain (Plain _) = True + paraOrPlain (Div _ nested) = all paraOrPlain nested + paraOrPlain _ = False unless (all paraOrPlain blks) $ lift $ P.report $ DocxParserWarning $ "Docx comment " <> cmtId <> " will not retain formatting" diff --git a/test/Tests/Readers/Docx.hs b/test/Tests/Readers/Docx.hs index 58818c56f..f975edd12 100644 --- a/test/Tests/Readers/Docx.hs +++ b/test/Tests/Readers/Docx.hs @@ -487,6 +487,11 @@ tests = [ testGroup "document" "comment warnings (all)" "docx/comments_warning.docx" ["Docx comment 1 will not retain formatting"] + , testForWarningsWithOpts def{readerTrackChanges=AllChanges, + readerExtensions=extensionsFromList [Ext_styles]} + "comments (with styles extension)" + "docx/comments.docx" + [] ] , testGroup "media" [ testMediaBag