Created
May 29, 2013 21:23
-
-
Save jgroszko/5673958 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/mezzanine/utils/html.py b/mezzanine/utils/html.py | |
index 8084efb..7fb58db 100644 | |
--- a/mezzanine/utils/html.py | |
+++ b/mezzanine/utils/html.py | |
@@ -3,6 +3,7 @@ from HTMLParser import HTMLParser, HTMLParseError | |
from htmlentitydefs import name2codepoint | |
import re | |
+SELF_CLOSING_TAGS = ['br', 'img'] | |
def decode_entities(html): | |
""" | |
@@ -47,7 +48,8 @@ class TagCloser(HTMLParser): | |
self.html += "".join(["</%s>" % tag for tag in self.tags]) | |
def handle_starttag(self, tag, attrs): | |
- self.tags.insert(0, tag) | |
+ if(tag not in SELF_CLOSING_TAGS): | |
+ self.tags.insert(0, tag) | |
def handle_endtag(self, tag): | |
try: |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment