a standard-conformant fix for sgml_tags
authorAurelien Campeas <aurelien.campeas@logilab.fr>
Tue, 21 Jul 2009 12:39:22 +0200
changeset 2399 68799e25f893
parent 2391 59a2def75e93
child 2400 17b1f0b80fe8
a standard-conformant fix for sgml_tags
common/uilib.py
--- a/common/uilib.py	Fri Jul 17 20:18:39 2009 +0200
+++ b/common/uilib.py	Tue Jul 21 12:39:22 2009 +0200
@@ -209,10 +209,13 @@
 
 # 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
 
-    content and attributes will be escaped
+    content and attri butes will be escaped
     """
     value = u'<%s' % tag
     if attrs:
@@ -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):