Code

Ticket #8123: utils-spaceless.diff

File utils-spaceless.diff, 658 bytes (added by julianb, 6 years ago)

First patch proposal

Line 
1Index: django/utils/html.py
2===================================================================
3--- django/utils/html.py        (revision 8200)
4+++ django/utils/html.py        (working copy)
5@@ -59,7 +59,9 @@
6 
7 def strip_spaces_between_tags(value):
8     """Returns the given HTML with spaces between tags removed."""
9-    return re.sub(r'>\s+<', '><', force_unicode(value))
10+    value = re.sub(r'>\s+<', '> <', force_unicode(value))
11+    value = re.sub(r'([^(em|strong|a)])>\s+<', r'\1><', value)
12+    return re.sub(r'>\s+<([^(em|strong|a)])', r'><\1', value)
13 strip_spaces_between_tags = allow_lazy(strip_spaces_between_tags, unicode)
14 
15 def strip_entities(value):