From 7825bd001c0ff7cb95940bed543dcc078d5b9d20 Mon Sep 17 00:00:00 2001 From: John MacFarlane Date: Thu, 7 May 2026 12:09:04 +0200 Subject: [PATCH] Markdown reader: don't produce empty Raw element with `--strip-comments`. Closes #11625. --- src/Text/Pandoc/Readers/Markdown.hs | 8 ++++++-- test/command/7521.md | 2 +- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/Text/Pandoc/Readers/Markdown.hs b/src/Text/Pandoc/Readers/Markdown.hs index 74e781781..f0f6744c6 100644 --- a/src/Text/Pandoc/Readers/Markdown.hs +++ b/src/Text/Pandoc/Readers/Markdown.hs @@ -1199,7 +1199,9 @@ rawHtmlBlocks = do return (return (B.rawBlock "html" $ stripMarkdownAttribute raw) <> contents <> return (B.rawBlock "html" rawcloser))) - <|> return (return (B.rawBlock "html" raw) <> contents) + <|> if T.all isSpace raw + then return mempty + else return (return (B.rawBlock "html" raw) <> contents) updateState $ \st -> st{ stateInHtmlBlock = oldInHtmlBlock } return result @@ -2190,7 +2192,9 @@ rawHtmlInline = do then (\x -> isInlineTag x && not (isCloseBlockTag x)) else not . isTextTag - return $ return $ B.rawInline "html" result + return $ if T.all isSpace result + then return mempty + else return $ B.rawInline "html" result -- Emoji diff --git a/test/command/7521.md b/test/command/7521.md index 4a24f13e1..88d15b495 100644 --- a/test/command/7521.md +++ b/test/command/7521.md @@ -5,7 +5,7 @@ - two ^D ```