mirror of
https://github.com/russross/blackfriday.git
synced 2024-03-22 13:40:34 +08:00
add HTML_NOFOLLOW_LINKS
This commit is contained in:
parent
5405274d99
commit
d71c759108
4
html.go
4
html.go
|
@ -30,6 +30,7 @@ const (
|
|||
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
|
||||
|
@ -499,6 +500,9 @@ func (options *Html) Link(out *bytes.Buffer, link []byte, title []byte, content
|
|||
out.WriteString("\" title=\"")
|
||||
attrEscape(out, title)
|
||||
}
|
||||
if options.flags&HTML_NOFOLLOW_LINKS != 0 {
|
||||
out.WriteString("\" rel=\"nofollow")
|
||||
}
|
||||
out.WriteString("\">")
|
||||
out.Write(content)
|
||||
out.WriteString("</a>")
|
||||
|
|
|
@ -421,6 +421,14 @@ func TestInlineLink(t *testing.T) {
|
|||
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",
|
||||
|
|
Loading…
Reference in New Issue
Block a user