mirror of
https://github.com/russross/blackfriday.git
synced 2024-03-22 13:40:34 +08:00
Add HTMLComment node type
This allows users of this library to handle HTML-comments different than other HTML blocks. Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
parent
4c9bf95126
commit
9e1787a26b
2
block.go
2
block.go
|
@ -430,7 +430,7 @@ func (p *Markdown) htmlComment(data []byte, doRender bool) int {
|
|||
for end > 0 && data[end-1] == '\n' {
|
||||
end--
|
||||
}
|
||||
block := p.addBlock(HTMLBlock, data[:end])
|
||||
block := p.addBlock(HTMLComment, data[:end])
|
||||
finalizeHTMLBlock(block)
|
||||
}
|
||||
return size
|
||||
|
|
4
html.go
4
html.go
|
@ -632,7 +632,7 @@ func (r *HTMLRenderer) RenderNode(w io.Writer, node *Node, entering bool) WalkSt
|
|||
// to be added and when not.
|
||||
if node.Prev != nil {
|
||||
switch node.Prev.Type {
|
||||
case HTMLBlock, List, Paragraph, Heading, CodeBlock, BlockQuote, HorizontalRule:
|
||||
case HTMLBlock, HTMLComment, List, Paragraph, Heading, CodeBlock, BlockQuote, HorizontalRule:
|
||||
r.cr(w)
|
||||
}
|
||||
}
|
||||
|
@ -654,7 +654,7 @@ func (r *HTMLRenderer) RenderNode(w io.Writer, node *Node, entering bool) WalkSt
|
|||
r.out(w, blockquoteCloseTag)
|
||||
r.cr(w)
|
||||
}
|
||||
case HTMLBlock:
|
||||
case HTMLBlock, HTMLComment:
|
||||
if r.Flags&SkipHTML != 0 {
|
||||
break
|
||||
}
|
||||
|
|
2
node.go
2
node.go
|
@ -26,6 +26,7 @@ const (
|
|||
Image
|
||||
Text
|
||||
HTMLBlock
|
||||
HTMLComment
|
||||
CodeBlock
|
||||
Softbreak
|
||||
Hardbreak
|
||||
|
@ -53,6 +54,7 @@ var nodeTypeNames = []string{
|
|||
Image: "Image",
|
||||
Text: "Text",
|
||||
HTMLBlock: "HTMLBlock",
|
||||
HTMLComment: "HTMLComment",
|
||||
CodeBlock: "CodeBlock",
|
||||
Softbreak: "Softbreak",
|
||||
Hardbreak: "Hardbreak",
|
||||
|
|
Loading…
Reference in New Issue
Block a user