Markdown raw HTML: fix handling of void hr element.

Closes #11793.

Added `voidTags` to unexported module
Text.Pandoc.Readers.HTML.TagCategories.
This commit is contained in:
John MacFarlane
2026-08-05 07:18:12 -07:00
parent f401468a1e
commit 12a44fbb98
3 changed files with 17 additions and 1 deletions
@@ -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"]
+2 -1
View File
@@ -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 <-
+9
View File
@@ -0,0 +1,9 @@
```
% pandoc -f markdown -t html
<div><hr></div>
^D
<div>
<hr>
</div>
```