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:
parent
7e9a57463f
commit
83b4cb6062
6
html.go
6
html.go
@ -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)
|
||||
|
@ -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})
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user