Skip to content

Commit

Permalink
Merge pull request #104 from mtrmac/comments
Browse files Browse the repository at this point in the history
Don't warn on top-level comments
  • Loading branch information
cpuguy83 committed Sep 28, 2023
2 parents 8363f7d + e2293e7 commit e8098c3
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
5 changes: 5 additions & 0 deletions md2man/roff.go
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,11 @@ func (r *roffRenderer) RenderNode(w io.Writer, node *blackfriday.Node, entering
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())
default:
fmt.Fprintln(os.Stderr, "WARNING: go-md2man does not handle node type "+node.Type.String())
}
Expand Down
14 changes: 14 additions & 0 deletions md2man/roff_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -398,6 +398,20 @@ July 2014, updated by Sven Dowideit (SvenDowideit@home.org.au)
doTestsInline(t, tests)
}

func TestComments(t *testing.T) {
blockTests := []string{
"First paragraph\n\n<!-- Comment, HTML should be separated by blank lines -->\n\nSecond paragraph\n",
".nh\n\n.PP\nFirst paragraph\n\n.PP\nSecond paragraph\n",
}
doTestsParam(t, blockTests, TestParams{})

inlineTests := []string{
"Text with a com<!--...-->ment in the middle\n",
".nh\n\n.PP\nText with a comment in the middle\n",
}
doTestsInlineParam(t, inlineTests, TestParams{})
}

func execRecoverableTestSuite(t *testing.T, tests []string, params TestParams, suite func(candidate *string)) {
// Catch and report panics. This is useful when running 'go test -v' on
// the integration server. When developing, though, crash dump is often
Expand Down

0 comments on commit e8098c3

Please sign in to comment.