all repos — grayfriday @ d71c7591087c576f285a39d05f2f3724acc54ab3

blackfriday fork with a few changes

add HTML_NOFOLLOW_LINKS
Graham Miller graham.miller@gmail.com
Tue, 25 Feb 2014 09:21:57 -0500
commit

d71c7591087c576f285a39d05f2f3724acc54ab3

parent

5405274d9994556c49bed724889558c8de335ffe

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

jump to
M html.gohtml.go

@@ -30,6 +30,7 @@ HTML_SKIP_IMAGES // skip embedded images

HTML_SKIP_LINKS // skip all links HTML_SKIP_SCRIPT // skip embedded <script> elements HTML_SAFELINK // only link to trusted protocols + HTML_NOFOLLOW_LINKS // only link with rel="nofollow" HTML_TOC // generate a table of contents HTML_OMIT_CONTENTS // skip the main contents (for a standalone table of contents) HTML_COMPLETE_PAGE // generate a complete HTML page

@@ -498,6 +499,9 @@ attrEscape(out, link)

if len(title) > 0 { out.WriteString("\" title=\"") attrEscape(out, title) + } + if options.flags&HTML_NOFOLLOW_LINKS != 0 { + out.WriteString("\" rel=\"nofollow") } out.WriteString("\">") out.Write(content)
M inline_test.goinline_test.go

@@ -421,6 +421,14 @@ }

doTestsInline(t, tests) } +func TestNofollowLink(t *testing.T) { + var tests = []string{ + "[foo](/bar/)\n", + "<p><a href=\"/bar/\" rel=\"nofollow\">foo</a></p>\n", + } + doTestsInlineParam(t, tests, 0, HTML_SAFELINK|HTML_NOFOLLOW_LINKS) +} + func TestSafeInlineLink(t *testing.T) { var tests = []string{ "[foo](/bar/)\n",