summaryrefslogtreecommitdiff
path: root/django/utils/html.py
diff options
context:
space:
mode:
authorTim Graham <timograham@gmail.com>2014-03-21 08:32:01 -0400
committerTim Graham <timograham@gmail.com>2014-03-21 08:50:43 -0400
commit8b81dee60c1533e714a310fa5c3907356042a64c (patch)
tree1c8d78cae84d3e502d284b8117d61f3737386177 /django/utils/html.py
parent99339c77f648fcdc30f6d914cb7efd902327ade7 (diff)
Removed fix_ampersands template filter per deprecation timeline.
Also removed related utility functions: * django.utils.html.fix_ampersands * django.utils.html.clean_html
Diffstat (limited to 'django/utils/html.py')
-rw-r--r--django/utils/html.py49
1 files changed, 0 insertions, 49 deletions
diff --git a/django/utils/html.py b/django/utils/html.py
index 6afd6b62fa..b9444fc01f 100644
--- a/django/utils/html.py
+++ b/django/utils/html.py
@@ -3,9 +3,7 @@
from __future__ import unicode_literals
import re
-import warnings
-from django.utils.deprecation import RemovedInDjango18Warning
from django.utils.encoding import force_text, force_str
from django.utils.functional import allow_lazy
from django.utils.safestring import SafeData, mark_safe
@@ -174,15 +172,6 @@ def strip_entities(value):
strip_entities = allow_lazy(strip_entities, six.text_type)
-def fix_ampersands(value):
- """Returns the given HTML with all unencoded ampersands encoded correctly."""
- # As fix_ampersands is wrapped in allow_lazy, stacklevel 3 is more useful than 2.
- warnings.warn("The fix_ampersands function is deprecated and will be removed in Django 1.8.",
- RemovedInDjango18Warning, stacklevel=3)
- return unencoded_ampersands_re.sub('&amp;', 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.
@@ -283,44 +272,6 @@ def urlize(text, trim_url_limit=None, nofollow=False, autoescape=False):
urlize = allow_lazy(urlize, six.text_type)
-def clean_html(text):
- """
- Clean the given HTML. Specifically, do the following:
- * Convert <b> and <i> to <strong> and <em>.
- * Encode all ampersands correctly.
- * Remove all "target" attributes from <a> tags.
- * Remove extraneous HTML, such as presentational tags that open and
- immediately close and <br clear="all">.
- * Convert hard-coded bullets into HTML unordered lists.
- * Remove stuff like "<p>&nbsp;&nbsp;</p>", but only if it's at the
- bottom of the text.
- """
- # As clean_html is wrapped in allow_lazy, stacklevel 3 is more useful than 2.
- warnings.warn("The clean_html function is deprecated and will be removed in Django 1.8.",
- RemovedInDjango18Warning, stacklevel=3)
- text = normalize_newlines(text)
- text = re.sub(r'<(/?)\s*b\s*>', '<\\1strong>', text)
- text = re.sub(r'<(/?)\s*i\s*>', '<\\1em>', text)
- text = fix_ampersands(text)
- # Remove all target="" attributes from <a> tags.
- text = link_target_attribute_re.sub('\\1', text)
- # Trim stupid HTML such as <br clear="all">.
- text = html_gunk_re.sub('', text)
- # Convert hard-coded bullets into HTML unordered lists.
-
- def replace_p_tags(match):
- s = match.group().replace('</p>', '</li>')
- for d in DOTS:
- s = s.replace('<p>%s' % d, '<li>')
- return '<ul>\n%s\n</ul>' % s
- text = hard_coded_bullets_re.sub(replace_p_tags, text)
- # Remove stuff like "<p>&nbsp;&nbsp;</p>", but only if it's at the bottom
- # of the text.
- text = trailing_empty_content_re.sub('', 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