-
Notifications
You must be signed in to change notification settings - Fork 66
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
Don't warn on top-level comments #104
Conversation
Add comment test cases Signed-off-by: Miloslav Trmač <[email protected]>
We should probably have an option to set the output of those logs (both to allow consumers to decide if they want logging, but it would also allow tests to verify the behavior). |
Interestingly, it looks like blackfriday already has code to handle HTML comments, but doesn't assign a dedicated type to it; go-md2man/vendor/github.com/russross/blackfriday/v2/block.go Lines 421 to 439 in 8363f7d
Mostly out of curiosity, I patched the vendor directory to see if it would work to assign a dedicated type for that, and it looks like that works, so perhaps I'll open a PR for that in blackfriday; diff --git a/md2man/roff.go b/md2man/roff.go
index c238a78..cc786db 100644
--- a/md2man/roff.go
+++ b/md2man/roff.go
@@ -165,13 +165,8 @@ func (r *roffRenderer) RenderNode(w io.Writer, node *blackfriday.Node, entering
return blackfriday.GoToNext
case blackfriday.TableCell:
r.handleTableCell(w, node, entering)
- case blackfriday.HTMLSpan:
- // ignore other HTML tags
- case blackfriday.HTMLBlock:
- if bytes.HasPrefix(node.Literal, []byte("<!--")) {
- break // ignore comments, no warning
- }
- fmt.Fprintln(os.Stderr, "WARNING: go-md2man does not handle node type "+node.Type.String())
+ case blackfriday.HTMLSpan, blackfriday.HTMLComment:
+ // ignore other HTML tags and comments
default:
fmt.Fprintln(os.Stderr, "WARNING: go-md2man does not handle node type "+node.Type.String())
}
diff --git a/vendor/github.com/russross/blackfriday/v2/block.go b/vendor/github.com/russross/blackfriday/v2/block.go
index dcd61e6..59d6235 100644
--- a/vendor/github.com/russross/blackfriday/v2/block.go
+++ b/vendor/github.com/russross/blackfriday/v2/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
diff --git a/vendor/github.com/russross/blackfriday/v2/node.go b/vendor/github.com/russross/blackfriday/v2/node.go
index 04e6050..299f54e 100644
--- a/vendor/github.com/russross/blackfriday/v2/node.go
+++ b/vendor/github.com/russross/blackfriday/v2/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", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thanks!
@cpuguy83 PTAL |
I published v2.0.3 with this patch (and a few others). |
Motivated by containers/image#2128 .
Run the tests with
-v
to see that there are no warnings.