Implement SkipHTML, add test

This commit is contained in:
Vytautas Šaltenis 2016-04-05 12:37:02 +03:00
parent 7e9a57463f
commit 83b4cb6062
2 changed files with 16 additions and 0 deletions

View File

@ -1133,6 +1133,9 @@ func (r *HTML) RenderNode(w io.Writer, node *Node, entering bool) WalkStatus {
r.out(w, tag("/del", nil, false)) r.out(w, tag("/del", nil, false))
} }
case HTMLSpan: case HTMLSpan:
if r.flags&SkipHTML != 0 {
break
}
if r.flags&SkipStyle != 0 && isHtmlTag(node.Literal, "style") { if r.flags&SkipStyle != 0 && isHtmlTag(node.Literal, "style") {
break break
} }
@ -1237,6 +1240,9 @@ func (r *HTML) RenderNode(w io.Writer, node *Node, entering bool) WalkStatus {
} }
break break
case HTMLBlock: case HTMLBlock:
if r.flags&SkipHTML != 0 {
break
}
r.cr(w) r.cr(w)
r.out(w, node.Literal) r.out(w, node.Literal)
r.cr(w) r.cr(w)

View File

@ -1158,3 +1158,13 @@ func TestUseXHTML(t *testing.T) {
"<hr />\n", "<hr />\n",
}, TestParams{HTMLFlags: UseXHTML}) }, TestParams{HTMLFlags: UseXHTML})
} }
func TestSkipHTML(t *testing.T) {
doTestsParam(t, []string{
"<div class=\"foo\"></div>\n\ntext\n\n<form>the form</form>",
"<p>text</p>\n",
"text <em>inline html</em> more text",
"<p>text inline html more text</p>\n",
}, TestParams{HTMLFlags: SkipHTML})
}