Ñò ŒOc@sJdZddkZddklZddklZddklZddk l Z l Z y e Z Wnej oeefZ nXdefd„ƒYZydd klZWnej on!Xd efd „ƒYZeƒZd „Zedd „Zeedd„Zeedd„Zedd„Zedd„ZeƒZdS(s? An interface to html5lib that mimics the lxml.html interface. iÿÿÿÿN(t HTMLParser(t TreeBuilder(tetree(t_contains_block_level_tagtXHTML_NAMESPACERcBseZdZed„ZRS(s*An html5lib HTML parser with lxml as tree.cKs ti|d|dt|dS(Ntstrictttree(t _HTMLParsert__init__R(tselfRtkwargs((s;/usr/lib/python2.6/vendor-packages/lxml/html/html5parser.pyRs(t__name__t __module__t__doc__tFalseR(((s;/usr/lib/python2.6/vendor-packages/lxml/html/html5parser.pyRs(t XHTMLParserRcBseZdZed„ZRS(s+An html5lib XHTML Parser with lxml as tree.cKs ti|d|dt|dS(NRR(t _XHTMLParserRR(R RR ((s;/usr/lib/python2.6/vendor-packages/lxml/html/html5parser.pyR#s(R R R RR(((s;/usr/lib/python2.6/vendor-packages/lxml/html/html5parser.pyR scCs8|i|ƒ}|dj o|S|idt|fƒS(Ns{%s}%s(tfindtNoneR(Rttagtelem((s;/usr/lib/python2.6/vendor-packages/lxml/html/html5parser.pyt _find_tag)s cCsPt|tƒptdƒ‚n|djo t}n|i|d|ƒiƒS(s%Parse a whole document into a string.sstring requiredt useChardetN(t isinstancet_stringst TypeErrorRt html_parsertparsetgetroot(thtmlt guess_charsettparser((s;/usr/lib/python2.6/vendor-packages/lxml/html/html5parser.pytdocument_fromstring0s   cCs°t|tƒptdƒ‚n|djo t}n|i|dd|ƒ}|oVt|dtƒoB|o7|diƒotid|dƒ‚n|d=q¬n|S(s”Parses several HTML elements, returning a list of elements. The first item in the list may be a string. If no_leading_text is true, then it will be an error if there is leading text, and it will always be a list of only elements. If `guess_charset` is `True` and the text was not unicode but a bytestring, the `chardet` library will perform charset guessing on the string. sstring requiredtdivRisThere is leading text: %rN( RRRRRt parseFragmenttstripRt ParserError(Rtno_leading_textRRtchildren((s;/usr/lib/python2.6/vendor-packages/lxml/html/html5parser.pytfragments_fromstring;s    c CsOt|tƒptdƒ‚nt|ƒ}t|d|d|d| t}|oot|tƒp d}nt|ƒ}|o=t|dtƒo|d|_|d=n|i |ƒn|S|pt i dƒ‚nt |ƒdjot i d ƒ‚n|d}|i o*|i iƒot i d |i ƒ‚nd |_ |S( sXParses a single HTML element; it is an error if there is more than one element, or if anything but whitespace precedes or follows the element. If create_parent is true (or is a tag name) then a parent node will be created to encapsulate the HTML in a single element. In this case, leading or trailing text is allowed. sstring requiredRRR%R!isNo elements foundisMultiple elements foundsElement followed by text: %rN(RRRtboolR'tkwt basestringtElementttexttextendRR$tlenttailR#R(Rt create_parentRRtaccept_leading_texttelementstnew_roottresult((s;/usr/lib/python2.6/vendor-packages/lxml/html/html5parser.pytfragment_fromstringWs2         cCs&t|tƒptdƒ‚nt|d|d|ƒ}|d iƒiƒ}|idƒp|idƒo|St|dƒ}t|ƒo|St|dƒ}t|ƒd joI|i p|i i ƒ o-|d i p|d i i ƒ o |d St |ƒo d |_ n d |_ |S(süParse the html, returning a single element/document. This tries to minimally parse the chunk of text, without knowing if it is a fragment or a document. base_url will set the document's base_url attribute (and the tree's docinfo.URL) sstring requiredRRi2sRR(((s;/usr/lib/python2.6/vendor-packages/lxml/html/html5parser.pyts2     (*