diff options
| author | Ray Ashman Jr <ray.ashman.jr@gmail.com> | 2013-11-02 19:53:29 -0400 |
|---|---|---|
| committer | Ray Ashman Jr <ray.ashman.jr@gmail.com> | 2013-11-02 19:53:29 -0400 |
| commit | e2ae8b048e7198428f696375b8bdcd89e90002d1 (patch) | |
| tree | 5788bd3c2a074e5c5c9f354db2e6e7ef1cbce2ad /django/utils/html.py | |
| parent | 3bc0d46a840f17dce561daca8a6b8690b2cf5d0a (diff) | |
Correct flake8 E302 violations
Diffstat (limited to 'django/utils/html.py')
| -rw-r--r-- | django/utils/html.py | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/django/utils/html.py b/django/utils/html.py index 6d04ae5205..3ad549de19 100644 --- a/django/utils/html.py +++ b/django/utils/html.py @@ -72,6 +72,7 @@ def conditional_escape(text): else: return escape(text) + def format_html(format_string, *args, **kwargs): """ Similar to str.format, but passes all arguments through conditional_escape, @@ -83,6 +84,7 @@ def format_html(format_string, *args, **kwargs): six.iteritems(kwargs)) return mark_safe(format_string.format(*args_safe, **kwargs_safe)) + def format_html_join(sep, format_string, args_generator): """ A wrapper of format_html, for the common case of a group of arguments that @@ -133,6 +135,7 @@ class MLStripper(HTMLParser): def get_data(self): return ''.join(self.fed) + def strip_tags(value): """Returns the given HTML with all tags stripped.""" s = MLStripper() @@ -145,6 +148,7 @@ def strip_tags(value): return s.get_data() strip_tags = allow_lazy(strip_tags) + def remove_tags(html, tags): """Returns the given HTML with given tags removed.""" tags = [re.escape(tag) for tag in tags.split()] @@ -156,21 +160,25 @@ def remove_tags(html, tags): return html remove_tags = allow_lazy(remove_tags, six.text_type) + def strip_spaces_between_tags(value): """Returns the given HTML with spaces between tags removed.""" return re.sub(r'>\s+<', '><', force_text(value)) strip_spaces_between_tags = allow_lazy(strip_spaces_between_tags, six.text_type) + def strip_entities(value): """Returns the given HTML with all entities (&something;) stripped.""" return re.sub(r'&(?:\w+|#\d+);', '', force_text(value)) strip_entities = allow_lazy(strip_entities, six.text_type) + def fix_ampersands(value): """Returns the given HTML with all unencoded ampersands encoded correctly.""" return unencoded_ampersands_re.sub('&', force_text(value)) fix_ampersands = allow_lazy(fix_ampersands, six.text_type) + def smart_urlquote(url): "Quotes a URL if it isn't already quoted." # Handle IDN before quoting. @@ -192,6 +200,7 @@ def smart_urlquote(url): return force_text(url) + def urlize(text, trim_url_limit=None, nofollow=False, autoescape=False): """ Converts any URLs in text into clickable links. @@ -269,6 +278,7 @@ def urlize(text, trim_url_limit=None, nofollow=False, autoescape=False): return ''.join(words) urlize = allow_lazy(urlize, six.text_type) + def clean_html(text): """ Clean the given HTML. Specifically, do the following: @@ -304,6 +314,7 @@ def clean_html(text): return text clean_html = allow_lazy(clean_html, six.text_type) + def avoid_wrapping(value): """ Avoid text wrapping in the middle of a phrase by adding non-breaking |
