From 12a44fbb985af2f9519cf2ad31957ae610fe0ba0 Mon Sep 17 00:00:00 2001 From: John MacFarlane Date: Wed, 5 Aug 2026 07:18:12 -0700 Subject: [PATCH] Markdown raw HTML: fix handling of void hr element. Closes #11793. Added `voidTags` to unexported module Text.Pandoc.Readers.HTML.TagCategories. --- src/Text/Pandoc/Readers/HTML/TagCategories.hs | 6 ++++++ src/Text/Pandoc/Readers/Markdown.hs | 3 ++- test/command/11793.md | 9 +++++++++ 3 files changed, 17 insertions(+), 1 deletion(-) create mode 100644 test/command/11793.md diff --git a/src/Text/Pandoc/Readers/HTML/TagCategories.hs b/src/Text/Pandoc/Readers/HTML/TagCategories.hs index e35ba4e39..aadc8f333 100644 --- a/src/Text/Pandoc/Readers/HTML/TagCategories.hs +++ b/src/Text/Pandoc/Readers/HTML/TagCategories.hs @@ -16,6 +16,7 @@ module Text.Pandoc.Readers.HTML.TagCategories , eitherBlockOrInline , epubTags , blockTags + , voidTags , sectioningContent , groupingContent ) @@ -68,6 +69,11 @@ epubTags = fromList ["case", "switch", "default"] blockTags :: Set Text blockTags = unions [blockHtmlTags, blockDocBookTags, epubTags] +voidTags :: Set Text +voidTags = fromList + ["area", "base", "br", "col", "embed", "hr", "img", "input", + "link", "meta", "param", "source", "track", "wbr"] + sectioningContent :: [Text] sectioningContent = ["article", "aside", "nav", "section"] diff --git a/src/Text/Pandoc/Readers/Markdown.hs b/src/Text/Pandoc/Readers/Markdown.hs index 896e5adeb..99a3fb434 100644 --- a/src/Text/Pandoc/Readers/Markdown.hs +++ b/src/Text/Pandoc/Readers/Markdown.hs @@ -50,6 +50,7 @@ import Text.Pandoc.Walk (walk) import Text.Pandoc.Parsing hiding (tableCaption) import Text.Pandoc.Readers.HTML (htmlInBalanced, htmlTag, isBlockTag, isInlineTag, isTextTag) +import Text.Pandoc.Readers.HTML.TagCategories (voidTags) import Text.Pandoc.Readers.LaTeX (applyMacros, rawLaTeXBlock, rawLaTeXInline) import Text.Pandoc.Shared import Text.Pandoc.URI (escapeURI, isURI, pBase64DataURI) @@ -1191,7 +1192,7 @@ rawHtmlBlocks = do gobbleAtMostSpaces indentlevel notFollowedBy' closer block - contents <- if selfClosing + contents <- if selfClosing || tagtype `Set.member` voidTags then return mempty else mconcat <$> many block' result <- diff --git a/test/command/11793.md b/test/command/11793.md new file mode 100644 index 000000000..48b7b2448 --- /dev/null +++ b/test/command/11793.md @@ -0,0 +1,9 @@ +``` +% pandoc -f markdown -t html +

+^D +
+
+
+``` +