diff --git a/py/xmlobj/html.py b/py/xmlobj/html.py index bf4410057..6e867b06a 100644 --- a/py/xmlobj/html.py +++ b/py/xmlobj/html.py @@ -10,6 +10,10 @@ class HtmlVisitor(SimpleUnicodeVisitor): single = dict([(x, 1) for x in ('br,img,area,param,col,hr,meta,link,base,' 'input,frame').split(',')]) + inline = dict([(x, 1) for x in + ('a abbr acronym b basefont bdo big br cite code dfn em font ' + 'i img input kbd label q s samp select small span strike ' + 'strong sub sup textarea tt u var'.split(' '))]) def repr_attribute(self, attrs, name): if name == 'class_': @@ -21,6 +25,9 @@ class HtmlVisitor(SimpleUnicodeVisitor): def _issingleton(self, tagname): return tagname in self.single + def _isinline(self, tagname): + return tagname in self.inline + class HtmlTag(Tag): def unicode(self, indent=2): l = [] diff --git a/py/xmlobj/testing/test_html.py b/py/xmlobj/testing/test_html.py index 8a6e8b2a6..2bf59c0f9 100644 --- a/py/xmlobj/testing/test_html.py +++ b/py/xmlobj/testing/test_html.py @@ -46,3 +46,9 @@ def test_singleton(): h = html.head(html.script(src="foo")) assert unicode(h) == '
' + +def test_inline(): + h = html.div(html.span('foo'), html.span('bar')) + assert (h.unicode(indent=2) == + 'literal
")) u = unicode(x) assert u == "literal