Skip to content

Instantly share code, notes, and snippets.

@jgroszko
Created May 29, 2013 21:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jgroszko/5673958 to your computer and use it in GitHub Desktop.
Save jgroszko/5673958 to your computer and use it in GitHub Desktop.
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