mirror of
https://github.com/jgm/pandoc.git
synced 2026-08-28 17:20:47 +08:00
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:
@@ -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"]
|
||||
|
||||
|
||||
@@ -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 <-
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
```
|
||||
% pandoc -f markdown -t html
|
||||
<div><hr></div>
|
||||
^D
|
||||
<div>
|
||||
<hr>
|
||||
</div>
|
||||
```
|
||||
|
||||
Reference in New Issue
Block a user