a standard-conformant fix for sgml_tags stable
authorAurelien Campeas <aurelien.campeas@logilab.fr>
Tue, 21 Jul 2009 12:38:10 +0200
branchstable
changeset 2398 a8d18e320ef3
parent 2397 cdedc2a32b06
child 2401 890f6b990dd7
a standard-conformant fix for sgml_tags
common/uilib.py
--- a/common/uilib.py	Tue Jul 21 11:48:11 2009 +0200
+++ b/common/uilib.py	Tue Jul 21 12:38:10 2009 +0200
@@ -209,6 +209,9 @@
 
 # HTML generation helper functions ############################################
 
+HTML4_EMPTY_TAGS = frozenset(('base', 'meta', 'link', 'hr', 'br', 'param',
+                              'img', 'area', 'input', 'col'))
+
 def simple_sgml_tag(tag, content=None, escapecontent=True, **attrs):
     """generation of a simple sgml tag (eg without children tags) easier
 
@@ -228,7 +231,10 @@
             content = xml_escape(unicode(content))
         value += u'>%s</%s>' % (content, tag)
     else:
-        value += u'></%s>' % tag
+        if tag in HTML4_EMPTY_TAGS:
+            value += u' />'
+        else:
+            value += u'></%s>' % tag
     return value
 
 def tooltipize(text, tooltip, url=None):