You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

20 lines
534 B

4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
  1. """A set of basic callbacks for bleach.linkify."""
  2. from __future__ import unicode_literals
  3. def nofollow(attrs, new=False):
  4. if attrs['href'].startswith('mailto:'):
  5. return attrs
  6. rel = [x for x in attrs.get('rel', '').split(' ') if x]
  7. if 'nofollow' not in [x.lower() for x in rel]:
  8. rel.append('nofollow')
  9. attrs['rel'] = ' '.join(rel)
  10. return attrs
  11. def target_blank(attrs, new=False):
  12. if attrs['href'].startswith('mailto:'):
  13. return attrs
  14. attrs['target'] = '_blank'
  15. return attrs