all repos — grayfriday @ 83b4cb6062026552be18b31998adc933abb2c39c

blackfriday fork with a few changes

Implement SkipHTML, add test
Vytautas Ĺ altenis vytas@rtfb.lt
Tue, 05 Apr 2016 12:37:02 +0300
commit

83b4cb6062026552be18b31998adc933abb2c39c

parent

7e9a57463ff1634bca3967415fb5c6e841eb8c3a

2 files changed, 16 insertions(+), 0 deletions(-)

jump to
M html.gohtml.go

@@ -1133,6 +1133,9 @@ } else {

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 @@ r.cr(w)

} break case HTMLBlock: + if r.flags&SkipHTML != 0 { + break + } r.cr(w) r.out(w, node.Literal) r.cr(w)
M inline_test.goinline_test.go

@@ -1158,3 +1158,13 @@ "---",

"<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}) +}