Ticket #3532: reintroduce_space.diff

File reintroduce_space.diff, 823 bytes (added by shugyoku, 7 years ago)

Reintroduce spaces for anchor tags that enclose text

  • django/utils/html.py

     
    5959
    6060def strip_spaces_between_tags(value):
    6161    """Returns the given HTML with spaces between tags removed."""
    62     return re.sub(r'>\s+<', '><', force_unicode(value))
     62    value = re.sub(r'>\s+<', '><', force_unicode(value))
     63    # Re-introduce the space between '/a>' and '<a ' adjacent anchor tags that enclose text
     64    # This is necessarily complex in order to avoid anchor tags between, say, 2 images having a space added   
     65    return re.sub(r'(\w)<\/a><a(\s+[^>]*)>(?=\w)', r'\1</a> <a\2>', force_unicode(value))
    6366strip_spaces_between_tags = allow_lazy(strip_spaces_between_tags, unicode)
    6467
    6568def strip_entities(value):
Back to Top