Skip to content

Commit 12a44fb

Browse files
committed
Markdown raw HTML: fix handling of void hr element.
Closes #11793. Added `voidTags` to unexported module Text.Pandoc.Readers.HTML.TagCategories.
1 parent f401468 commit 12a44fb

3 files changed

Lines changed: 17 additions & 1 deletion

File tree

src/Text/Pandoc/Readers/HTML/TagCategories.hs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ module Text.Pandoc.Readers.HTML.TagCategories
1616
, eitherBlockOrInline
1717
, epubTags
1818
, blockTags
19+
, voidTags
1920
, sectioningContent
2021
, groupingContent
2122
)
@@ -68,6 +69,11 @@ epubTags = fromList ["case", "switch", "default"]
6869
blockTags :: Set Text
6970
blockTags = unions [blockHtmlTags, blockDocBookTags, epubTags]
7071

72+
voidTags :: Set Text
73+
voidTags = fromList
74+
["area", "base", "br", "col", "embed", "hr", "img", "input",
75+
"link", "meta", "param", "source", "track", "wbr"]
76+
7177
sectioningContent :: [Text]
7278
sectioningContent = ["article", "aside", "nav", "section"]
7379

src/Text/Pandoc/Readers/Markdown.hs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ import Text.Pandoc.Walk (walk)
5050
import Text.Pandoc.Parsing hiding (tableCaption)
5151
import Text.Pandoc.Readers.HTML (htmlInBalanced, htmlTag, isBlockTag,
5252
isInlineTag, isTextTag)
53+
import Text.Pandoc.Readers.HTML.TagCategories (voidTags)
5354
import Text.Pandoc.Readers.LaTeX (applyMacros, rawLaTeXBlock, rawLaTeXInline)
5455
import Text.Pandoc.Shared
5556
import Text.Pandoc.URI (escapeURI, isURI, pBase64DataURI)
@@ -1191,7 +1192,7 @@ rawHtmlBlocks = do
11911192
gobbleAtMostSpaces indentlevel
11921193
notFollowedBy' closer
11931194
block
1194-
contents <- if selfClosing
1195+
contents <- if selfClosing || tagtype `Set.member` voidTags
11951196
then return mempty
11961197
else mconcat <$> many block'
11971198
result <-

test/command/11793.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
```
2+
% pandoc -f markdown -t html
3+
<div><hr></div>
4+
^D
5+
<div>
6+
<hr>
7+
</div>
8+
```
9+

0 commit comments

Comments
 (0)