Mercurial > repos > shellac > guppy_basecaller
comparison env/lib/python3.7/site-packages/bleach/callbacks.py @ 2:6af9afd405e9 draft
"planemo upload commit 0a63dd5f4d38a1f6944587f52a8cd79874177fc1"
author | shellac |
---|---|
date | Thu, 14 May 2020 14:56:58 -0400 |
parents | 26e78fe6e8c4 |
children |
comparison
equal
deleted
inserted
replaced
1:75ca89e9b81c | 2:6af9afd405e9 |
---|---|
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 |