all repos — grayfriday @ e078bb8ec34db7cc285f347d24f367b95c909ece

blackfriday fork with a few changes

Merge pull request #52 from laslowh/master

add HTML_NOFOLLOW_LINKS
Vytautas Ĺ altenis vytas@rtfb.lt
Mon, 10 Mar 2014 21:47:35 +0200
commit

e078bb8ec34db7cc285f347d24f367b95c909ece

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",