html5lib / gcode-import

Automatically exported from code.google.com/p/html5lib. Purely archival.
Other
7 stars 8 forks source link

Empty elements and self closing tags #196

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
SimpleTree replace an empty element (for example <p></p>)
with a self closed element (<p />) in it's toxml() method. 
This is XHTML valid, but not HTML valid.
http://dev.w3.org/html5/html-author/#elements

Is there a way to choose between XHTML output and HTML output in the html5lib ?

What is the expected output? What do you see instead?

>>>import html5lib
>>>p = html5lib.HTMLParser()
>>>print p.parse("<a name='anchor_name'></a>").toxml()
<html><head></head><body><a name='anchor_name' /></body></html>

instead of :
<html><head></head><body><a name='anchor_name'></a></body></html>

Original issue reported on code.google.com by adrien.d...@gmail.com on 16 Jan 2012 at 3:28

GoogleCodeExporter commented 9 years ago
import html5lib
p = html5lib.HTMLParser()
doc = p.parse("<a name='anchor_name'></a>")
print html5lib.serialize(doc)

Original comment by t.broyer on 16 Jan 2012 at 6:19

GoogleCodeExporter commented 9 years ago
Ok, thanks.

Actually i'm using django with django-cms 2.0. When django cms saves a text 
(formatted with TinyMCE), it sanitize the content with html5lib.

So when I enter "<a name='anchor'></a>", django-cms saves "<a name='anchor'/>" 
into database.
It looks like it's a django-cms problem.

Thanks for the quick answer !

Original comment by adrien.d...@gmail.com on 17 Jan 2012 at 11:07