Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add HTMLComment node type #714

Open
wants to merge 1 commit into
base: v2
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion block.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions html.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}
Expand All @@ -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
}
Expand Down
2 changes: 2 additions & 0 deletions node.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ const (
Image
Text
HTMLBlock
HTMLComment
CodeBlock
Softbreak
Hardbreak
Expand Down Expand Up @@ -53,6 +54,7 @@ var nodeTypeNames = []string{
Image: "Image",
Text: "Text",
HTMLBlock: "HTMLBlock",
HTMLComment: "HTMLComment",
CodeBlock: "CodeBlock",
Softbreak: "Softbreak",
Hardbreak: "Hardbreak",
Expand Down