Implement SkipStyle, add test

Fix a bug in findHtmlTagPos introduced with e02c392d.
This commit is contained in:
Vytautas Šaltenis 2016-04-05 12:13:37 +03:00
parent fecfec2059
commit 7e9a57463f
2 changed files with 13 additions and 1 deletions

View File

@ -884,7 +884,7 @@ func findHtmlTagPos(tag []byte, tagname string) (bool, int) {
}
rightAngle := skipUntilCharIgnoreQuotes(tag, i, '>')
if rightAngle > i {
if rightAngle >= i {
return true, rightAngle
}
@ -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&SkipStyle != 0 && isHtmlTag(node.Literal, "style") {
break
}
//if options.safe {
// out(w, "<!-- raw HTML omitted -->")
//} else {

View File

@ -1139,6 +1139,15 @@ func TestSkipImages(t *testing.T) {
})
}
func TestSkipStyle(t *testing.T) {
doTestsInlineParam(t, []string{
"foo\n\n<style>color: #f00</style> bar",
"<p>foo</p>\n\n<p>color: #f00 bar</p>\n",
}, TestParams{
HTMLFlags: SkipStyle,
})
}
func TestUseXHTML(t *testing.T) {
doTestsParam(t, []string{
"---",