Mercurial > repos > guerler > springsuite
comparison planemo/lib/python3.7/site-packages/bleach/callbacks.py @ 0:d30785e31577 draft
"planemo upload commit 6eee67778febed82ddd413c3ca40b3183a3898f1"
| author | guerler |
|---|---|
| date | Fri, 31 Jul 2020 00:18:57 -0400 |
| parents | |
| children |
comparison
equal
deleted
inserted
replaced
| -1:000000000000 | 0:d30785e31577 |
|---|---|
| 1 """A set of basic callbacks for bleach.linkify.""" | |
| 2 from __future__ import unicode_literals | |
| 3 | |
| 4 | |
| 5 def nofollow(attrs, new=False): | |
| 6 href_key = (None, 'href') | |
| 7 | |
| 8 if href_key not in attrs: | |
| 9 return attrs | |
| 10 | |
| 11 if attrs[href_key].startswith('mailto:'): | |
| 12 return attrs | |
| 13 | |
| 14 rel_key = (None, 'rel') | |
| 15 rel_values = [val for val in attrs.get(rel_key, '').split(' ') if val] | |
| 16 if 'nofollow' not in [rel_val.lower() for rel_val in rel_values]: | |
| 17 rel_values.append('nofollow') | |
| 18 attrs[rel_key] = ' '.join(rel_values) | |
| 19 | |
| 20 return attrs | |
| 21 | |
| 22 | |
| 23 def target_blank(attrs, new=False): | |
| 24 href_key = (None, 'href') | |
| 25 | |
| 26 if href_key not in attrs: | |
| 27 return attrs | |
| 28 | |
| 29 if attrs[href_key].startswith('mailto:'): | |
| 30 return attrs | |
| 31 | |
| 32 attrs[(None, 'target')] = '_blank' | |
| 33 return attrs |
