U e @sVdZddlmZmZddlmZmZGdddZGdddZGdd d ej Z d S) z Legacy module - don't use in new code! html5lib now has its own proper implementation. This module implements a tree builder for html5lib that generates lxml html element trees. This module uses camelCase as it follows the html5lib style guide. )_baseetree)htmlrc@seZdZddZdS) DocumentTypecCs||_||_||_dSN)namepublicIdsystemId)selfrrr r G/opt/hc_python/lib64/python3.8/site-packages/lxml/html/_html5builder.py__init__szDocumentType.__init__N)__name__ __module__ __qualname__r r r r r rsrc@seZdZddZddZdS)DocumentcCsd|_g|_dSr) _elementTree childNodesr r r r r szDocument.__init__cCs|j|jdSr)rZgetrootZaddnext_element)r elementr r r appendChildszDocument.appendChildN)rrrr rr r r r rsrc@sZeZdZeZeZdZdZeZ ddZ ddZ ddZ dd Z d d Zdd d ZddZdS) TreeBuilderNcOsDtjtdd}tjtdd}|j|_|j|_tj j |f||dS)NF)ZfullTree) etree_buildersZgetETreeModulerrZElement elementClassComment commentClassrrr )r argskwargsZ html_builderZ etree_builderr r r r 's zTreeBuilder.__init__cCs"tj|d|_g|_d|_dS)NF)rrreset rootInsertedinitialCommentsdoctyperr r r r.s zTreeBuilder.resetcCs|jjSr)documentrrr r r getDocument4szTreeBuilder.getDocumentcCsFg}|jdj}|jr"||j|||jrB||j|S)Nr) openElementsrtextappendextendZ getchildrentail)r fragmentrr r r getFragment7s   zTreeBuilder.getFragmentcCs||||}||_dSr) doctypeClassr")r rrr r"r r r insertDoctypeAszTreeBuilder.insertDoctypecCs(|js|j|ntj|||dSr)r r!r'rr insertComment)r dataparentr r r r.EszTreeBuilder.insertCommentcCsg}|jr`|jjr`|d|jj|jjdk s<|jjdk rV|d|jj|jjf|d|dtd|}|jD]}| t |q| |_ ||j _||}||_|j j||j|d|_dS)Nz z T)r"rr'rr r fromstringjoinr!Z addpreviousrr documentClassr#Z getroottreerrrrr%r )r rbufrootcommentZ root_elementr r r insertRootKs&        zTreeBuilder.insertRoot)N)rrrrr5rr,rrZ fragmentClassr rr$r+r-r.r9r r r r r s  rN) __doc__Zhtml5lib.treebuildersrrrZlxmlrrrrr r r r s