Ńň žŞJc @s&dZddkZddklZlZddklZddk l Z l Z ddk l Z y eZWnej oeefZnXdefd„ƒYZd efd „ƒYZd „Zedd „Zeedd „Zeedd„Zedd„Zedd„ZeƒZeƒZdS(s An interface to html5lib. i˙˙˙˙N(t HTMLParsert XHTMLParser(tetree(t_contains_block_level_tagtXHTML_NAMESPACE(t TreeBuilderRcBseZdZed„ZRS(s*An html5lib HTML parser with lxml as tree.cCsti|d|dtƒdS(Ntstrictttree(t _HTMLParsert__init__R(tselfR((s;/usr/lib64/python2.6/site-packages/lxml/html/html5parser.pyR s(t__name__t __module__t__doc__tFalseR (((s;/usr/lib64/python2.6/site-packages/lxml/html/html5parser.pyRsRcBseZdZed„ZRS(s+An html5lib XHTML Parser with lxml as tree.cCsti|d|dtƒdS(NRR(t _XHTMLParserR R(R R((s;/usr/lib64/python2.6/site-packages/lxml/html/html5parser.pyR s(R R R RR (((s;/usr/lib64/python2.6/site-packages/lxml/html/html5parser.pyRscCs8|i|ƒ}|dj o|S|idt|fƒS(Ns{%s}%s(tfindtNoneR(Rttagtelem((s;/usr/lib64/python2.6/site-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/lib64/python2.6/site-packages/lxml/html/html5parser.pytdocument_fromstring's   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/lib64/python2.6/site-packages/lxml/html/html5parser.pytfragments_fromstring2s    cCsët|tƒptdƒ‚n|o$|pd}d|||f}nt|t||ƒ}|ptidƒ‚nt|ƒdjotidƒ‚n|d}|io*|ii ƒotid|iƒ‚nd |_|S( s Parses 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. sstring requiredR s <%s>%ssNo elements foundisMultiple elements foundisElement followed by text: %rN( RRRR&tTrueRR#tlenttailR"R(Rt create_parentRRt containerR%tresult((s;/usr/lib64/python2.6/site-packages/lxml/html/html5parser.pytfragment_fromstringNs    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 requiredRRi2ss*    *