add HTML_NOFOLLOW_LINKS
Graham Miller graham.miller@gmail.com
Tue, 25 Feb 2014 09:21:57 -0500
2 files changed,
12 insertions(+),
0 deletions(-)
M
html.go
→
html.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.go
→
inline_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",