Permalink
Browse files

Open in a new window

  • Loading branch information...
1 parent c0e0fe1 commit 7cf6b4d8153bc689bfa45413c798031d62f9d1f8 @lsemel committed Apr 10, 2012
View
@@ -72,19 +72,19 @@ def auto_link_usernames_or_lists(self, **kwargs):
}
kwargs.update(defaults)
extra_html = kwargs.get('suppress_no_follow', False) or self.HTML_ATTR_NO_FOLLOW
-
+
matches = REGEXEN['auto_link_usernames_or_lists'].finditer(self.text)
for match in matches:
_link = match.group(0)
if match.group(4) is not None and not kwargs.get('suppress_lists', False):
# this link is a list
_list = u'%s%s' % (match.group(3), match.group(4))
- _link = u'%s%s<a class="%s" href="%s%s"%s>%s</a>' % ( match.group(1), match.group(2), ' '.join( [ kwargs.get('url_class', ''), kwargs.get('list_class', '') ] ), kwargs.get('list_url_base'), _list.lower(), extra_html, _list )
+ _link = u'%s%s<a target="_blank" class="%s" href="%s%s"%s>%s</a>' % ( match.group(1), match.group(2), ' '.join( [ kwargs.get('url_class', ''), kwargs.get('list_class', '') ] ), kwargs.get('list_url_base'), _list.lower(), extra_html, _list )
del(_list)
else:
# this is a screen name
_username = match.group(3)
- _link = u'%s<a class="%s" href="%s%s"%s>%s%s</a>' % ( match.group(1), ' '.join( [ kwargs.get('url_class'), kwargs.get('username_class', '') ] ), kwargs.get('username_url_base', ''), _username, extra_html, match.group(2), _username )
+ _link = u'%s<a target="_blank" class="%s" href="%s%s"%s>%s%s</a>' % ( match.group(1), ' '.join( [ kwargs.get('url_class'), kwargs.get('username_class', '') ] ), kwargs.get('username_url_base', ''), _username, extra_html, match.group(2), _username )
del(_username)
self.text = self.text.replace(match.group(0), _link)
del(_link)
@@ -118,10 +118,10 @@ def auto_link_hashtags(self, **kwargs):
}
kwargs.update(defaults)
extra_html = kwargs.get('suppress_no_follow', False) or self.HTML_ATTR_NO_FOLLOW
-
+
matches = REGEXEN['auto_link_hashtags'].finditer(self.text)
for match in matches:
- _link = u'%s<a href="%s%s" title="#%s" class="%s"%s>%s%s</a>' % ( match.group(1), kwargs.get('hashtag_url_base'), match.group(3), match.group(3), ' '.join( [ kwargs.get('url_class', ''), kwargs.get('hashtag_class', '') ] ), extra_html, match.group(2), match.group(3) )
+ _link = u'%s<a target="_blank"href="%s%s" title="#%s" class="%s"%s>%s%s</a>' % ( match.group(1), kwargs.get('hashtag_url_base'), match.group(3), match.group(3), ' '.join( [ kwargs.get('url_class', ''), kwargs.get('hashtag_class', '') ] ), extra_html, match.group(2), match.group(3) )
self.text = self.text.replace(match.group(0), _link)
if self.parent and hasattr(self.parent, 'text'):
Binary file not shown.
@@ -17,6 +17,6 @@ def twitter_text(text, search_query = False):
tt = TwitterText(text)
if search_query:
tt.highlighter.hit_highlight(search_query)
- tt.autolink.auto_link()
+ tt.autolink.auto_link(html_attrs={'target':'_blank'})
return tt.text
twitter_text.is_safe = True
Binary file not shown.

0 comments on commit 7cf6b4d

Please sign in to comment.