This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author Chenyun Yang
Recipients Chenyun Yang
Date 2015-09-28.19:26:34
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1443468394.25.0.617953373069.issue25258@psf.upfronthosting.co.za>
In-reply-to
Content
For void elements such as (<link>, <img>), there doesn't need to have xhtml empty end tag. HtmlParser which relies on the XHTML empty end syntax failed to handle this situation. 

from HTMLParser import HTMLParser

# create a subclass and override the handler methods
class MyHTMLParser(HTMLParser):
    def handle_starttag(self, tag, attrs):
        print "Encountered a start tag:", tag
    def handle_endtag(self, tag):
        print "Encountered an end tag :", tag
    def handle_data(self, data):
        print "Encountered some data  :", data

>>> parser.feed('<link rel="import"><img src="som">')
Encountered a start tag: link
Encountered a start tag: img
>>> parser.feed('<link rel="import"/><img src="som"/>')
Encountered a start tag: link
Encountered an end tag : link
Encountered a start tag: img
Encountered an end tag : img


Reference:
https://github.com/python/cpython/blob/bdfb14c688b873567d179881fc5bb67363a6074c/Lib/html/parser.py
http://www.w3.org/TR/html5/syntax.html#void-elements
History
Date User Action Args
2015-09-28 19:26:34Chenyun Yangsetrecipients: + Chenyun Yang
2015-09-28 19:26:34Chenyun Yangsetmessageid: <1443468394.25.0.617953373069.issue25258@psf.upfronthosting.co.za>
2015-09-28 19:26:34Chenyun Yanglinkissue25258 messages
2015-09-28 19:26:34Chenyun Yangcreate