1
0
mirror of https://github.com/danog/blackfriday.git synced 2025-01-23 05:41:27 +01:00

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))
}
case HTMLSpan:
if r.flags&SkipHTML != 0 {
break
}
if r.flags&SkipStyle != 0 && isHtmlTag(node.Literal, "style") {
break
}
@ -1237,6 +1240,9 @@ func (r *HTML) RenderNode(w io.Writer, node *Node, entering bool) WalkStatus {
}
break
case HTMLBlock:
if r.flags&SkipHTML != 0 {
break
}
r.cr(w)
r.out(w, node.Literal)
r.cr(w)

View File

@ -1158,3 +1158,13 @@ func TestUseXHTML(t *testing.T) {
"<hr />\n",
}, 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})
}