<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0-alpha1/dist/css/bootstrap.min.css" rel="stylesheet"
        integrity="sha384-GLhlTQ8iRABdZLl6O3oVMWSktQOp6b7In1Zl3/Jr59b6EGGoI1aFkw7cmDA6j6gD" crossorigin="anonymous">
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.3.0/css/all.min.css"
        integrity="sha512-SzlrxWUlpfuzQ+pcUCosxcglQRNAq/DZjVsC0lE40xsADsfeQoEypE+enwcOiGjk/bSuGGKHEyjSoQ1zVisanQ=="
        crossorigin="anonymous" referrerpolicy="no-referrer" />
</head>
</html>
3
ÝPfv6  ã               @   sú   d dl mZmZmZ d dlmZ ddlmZmZm	Z	 dZ
eeƒdfeeee	d dfgƒB ƒdfeeee	d d	fe	d d
fgƒB ƒdfee	d dfe	d dfgƒdfee	d dfe	d dfgƒdfdœZG dd„ deƒZG dd„ deƒZG dd„ deƒZdS )é    )Úabsolute_importÚdivisionÚunicode_literals)Ú	text_typeé   )ÚscopingElementsÚtableInsertModeElementsÚ
namespacesNFÚhtmlÚbuttonZolZulÚtableÚoptgroupÚoptionT)Nr   Úlistr   Zselectc               @   s^   e Zd Zdd„ Zdd„ Zdd„ Zdd„ Zdd
d„Zdd„ Zdd„ Z	dd„ Z
dd„ Zdd„ Zd	S )ÚNodec             C   s(   || _ d| _d| _i | _g | _g | _dS )a6  Node representing an item in the tree.
        name - The tag name associated with the node
        parent - The parent of the current node (or None for the document node)
        value - The value of the current node (applies to text nodes and
        comments
        attributes - a dict holding name, value pairs for attributes of the node
        childNodes - a list of child nodes of the current node. This must
        include all elements but not necessarily other node types
        _flags - A list of miscellaneous flags that can be set on the node
        N)ÚnameÚparentÚvalueÚ
attributesÚ
childNodesZ_flags)Úselfr   © r   ú/usr/lib/python3.6/base.pyÚ__init__   s    zNode.__init__c             C   s:   dj dd„ | jjƒ D ƒƒ}|r,d| j|f S d| j S d S )Nú c             S   s   g | ]\}}d ||f ‘qS )z%s="%s"r   )Ú.0r   r   r   r   r   ú
<listcomp>+   s   z Node.__str__.<locals>.<listcomp>z<%s %s>z<%s>)Újoinr   Úitemsr   )r   ZattributesStrr   r   r   Ú__str__*   s
    
zNode.__str__c             C   s
   d| j  S )Nz<%s>)r   )r   r   r   r   Ú__repr__3   s    zNode.__repr__c             C   s   t ‚dS )z3Insert node as a child of the current node
        N)ÚNotImplementedError)r   Únoder   r   r   ÚappendChild6   s    zNode.appendChildNc             C   s   t ‚dS )zŒInsert data as text in the current node, positioned before the
        start of node insertBefore or to the end of the node's text.
        N)r!   )r   ÚdataÚinsertBeforer   r   r   Ú
insertText;   s    zNode.insertTextc             C   s   t ‚dS )z¦Insert node as a child of the current node, before refNode in the
        list of child nodes. Raises ValueError if refNode is not a child of
        the current nodeN)r!   )r   r"   ZrefNoder   r   r   r%   A   s    zNode.insertBeforec             C   s   t ‚dS )z:Remove node from the children of the current node
        N)r!   )r   r"   r   r   r   ÚremoveChildG   s    zNode.removeChildc             C   s$   x| j D ]}|j|ƒ qW g | _ dS )z­Move all the children of the current node to newParent.
        This is needed so that trees that don't store text as nodes move the
        text in the correct way
        N)r   r#   )r   Z	newParentZchildr   r   r   ÚreparentChildrenL   s    zNode.reparentChildrenc             C   s   t ‚dS )zŠReturn a shallow copy of the current node i.e. a node with the same
        name and attributes but with no parent or child nodes
        N)r!   )r   r   r   r   Ú	cloneNodeV   s    zNode.cloneNodec             C   s   t ‚dS )zFReturn true if the node has children or text, false otherwise
        N)r!   )r   r   r   r   Ú
hasContent\   s    zNode.hasContent)N)Ú__name__Ú
__module__Ú__qualname__r   r   r    r#   r&   r%   r'   r(   r)   r*   r   r   r   r   r      s   	

r   c               @   s   e Zd Zdd„ Zdd„ ZdS )ÚActiveFormattingElementsc             C   sf   d}|t krVxH| d d d… D ]6}|t kr*P | j||ƒr>|d7 }|dkr| j|ƒ P qW tj| |ƒ d S )Nr   é   é   éÿÿÿÿ)ÚMarkerÚ
nodesEqualÚremover   Úappend)r   r"   Z
equalCountÚelementr   r   r   r5   c   s    
zActiveFormattingElements.appendc             C   s$   |j |j ksdS |j|jks dS dS )NFT)Ú	nameTupler   )r   Znode1Znode2r   r   r   r3   p   s
    z#ActiveFormattingElements.nodesEqualN)r+   r,   r-   r5   r3   r   r   r   r   r.   b   s   r.   c               @   sÖ   e Zd ZdZdZdZdZdZdZdd„ Z	dd„ Z
d+dd„Zd	d
„ Zdd„ Zdd„ Zdd„ Zdd„ Zd,dd„Zdd„ Zdd„ Zdd„ ZeeeƒZdd„ Zdd„ Zd-dd „Zd!d"„ Zd.d#d$„Zd%d&„ Zd'd(„ Zd)d*„ ZdS )/ÚTreeBuildera  Base treebuilder implementation
    documentClass - the class to use for the bottommost node of a document
    elementClass - the class to use for HTML Elements
    commentClass - the class to use for comments
    doctypeClass - the class to use for doctypes
    Nc             C   s   |rd| _ nd | _ | jƒ  d S )Nzhttp://www.w3.org/1999/xhtml)ÚdefaultNamespaceÚreset)r   ZnamespaceHTMLElementsr   r   r   r   ’   s    zTreeBuilder.__init__c             C   s.   g | _ tƒ | _d | _d | _d| _| jƒ | _d S )NF)ÚopenElementsr.   ÚactiveFormattingElementsZheadPointerZformPointerÚinsertFromTableÚdocumentClassÚdocument)r   r   r   r   r:   ™   s    zTreeBuilder.resetc             C   s~   t |dƒ}|s$t|tƒr$td |f}t| \}}xHt| jƒD ]:}|rP||krPdS | rd|j|krddS ||j|kA r<dS q<W d S )Nr7   r
   TF)ÚhasattrÚ
isinstancer   r	   ÚlistElementsMapÚreversedr;   r7   )r   ÚtargetZvariantZ	exactNodeZlistElementsÚinvertr"   r   r   r   ÚelementInScope¥   s    

zTreeBuilder.elementInScopec             C   sÈ   | j s
d S t| j ƒd }| j | }|tks4|| jkr8d S x6|tkrn|| jkrn|dkrZd}P |d8 }| j | }q:W xR|d7 }| j | }|jƒ }| jd|j|j|jdœƒ}|| j |< || j d krrP qrW d S )Nr/   r   ZStartTag)Útyper   Ú	namespacer$   r1   r1   )	r<   Úlenr2   r;   r)   ÚinsertElementr   rH   r   )r   ÚiÚentryZcloner6   r   r   r   Ú#reconstructActiveFormattingElements»   s.    


z/TreeBuilder.reconstructActiveFormattingElementsc             C   s,   | j jƒ }x| j r&|tkr&| j jƒ }qW d S )N)r<   Úpopr2   )r   rL   r   r   r   ÚclearActiveFormattingElementsé   s    
z)TreeBuilder.clearActiveFormattingElementsc             C   s8   x2| j ddd… D ]}|tkr"P q|j|kr|S qW dS )zšCheck if an element exists between the end of the active
        formatting elements and the last marker. If it does, return it, else
        return falseNr/   Fr1   )r<   r2   r   )r   r   Úitemr   r   r   Ú!elementInActiveFormattingElementsî   s    
z-TreeBuilder.elementInActiveFormattingElementsc             C   s&   | j |ƒ}| jj|ƒ | jj|ƒ d S )N)ÚcreateElementr;   r5   r?   r#   )r   Útokenr6   r   r   r   Ú
insertRootü   s    
zTreeBuilder.insertRootc             C   s6   |d }|d }|d }| j |||ƒ}| jj|ƒ d S )Nr   ÚpublicIdÚsystemId)ÚdoctypeClassr?   r#   )r   rS   r   rU   rV   Zdoctyper   r   r   ÚinsertDoctype  s
    zTreeBuilder.insertDoctypec             C   s*   |d kr| j d }|j| j|d ƒƒ d S )Nr/   r$   r1   )r;   r#   ÚcommentClass)r   rS   r   r   r   r   ÚinsertComment	  s    
zTreeBuilder.insertCommentc             C   s0   |d }|j d| jƒ}| j||ƒ}|d |_|S )z.Create an element but don't insert it anywherer   rH   r$   )Úgetr9   ÚelementClassr   )r   rS   r   rH   r6   r   r   r   rR     s
    
zTreeBuilder.createElementc             C   s   | j S )N)Ú_insertFromTable)r   r   r   r   Ú_getInsertFromTable  s    zTreeBuilder._getInsertFromTablec             C   s    || _ |r| j| _n| j| _dS )zsSwitch the function used to insert an element from the
        normal one to the misnested table one and back againN)r]   ÚinsertElementTablerJ   ÚinsertElementNormal)r   r   r   r   r   Ú_setInsertFromTable  s    
zTreeBuilder._setInsertFromTablec             C   sL   |d }|j d| jƒ}| j||ƒ}|d |_| jd j|ƒ | jj|ƒ |S )Nr   rH   r$   r/   r1   )r[   r9   r\   r   r;   r#   r5   )r   rS   r   rH   r6   r   r   r   r`   $  s    
zTreeBuilder.insertElementNormalc             C   s`   | j |ƒ}| jd jtkr$| j|ƒS | jƒ \}}|dkrD|j|ƒ n|j||ƒ | jj|ƒ |S )z-Create an element and insert it into the treer/   Nr1   )	rR   r;   r   r   r`   ÚgetTableMisnestedNodePositionr#   r%   r5   )r   rS   r6   r   r%   r   r   r   r_   .  s    

zTreeBuilder.insertElementTablec             C   sX   |dkr| j d }| j s0| jr<| j d jtkr<|j|ƒ n| jƒ \}}|j||ƒ dS )zInsert text data.Nr/   r1   r1   )r;   r=   r   r   r&   rb   )r   r$   r   r%   r   r   r   r&   >  s    

zTreeBuilder.insertTextc             C   sv   d}d}d}x(| j ddd… D ]}|jdkr|}P qW |rd|jrL|j}|}qn| j | j j|ƒd  }n
| j d }||fS )zsGet the foster parent element, and sibling to insert before
        (or None) when inserting a misnested table nodeNr/   r   r   r1   )r;   r   r   Úindex)r   Z	lastTableZfosterParentr%   Zelmr   r   r   rb   M  s    

z)TreeBuilder.getTableMisnestedNodePositionc          
   C   s8   | j d
 j}|tdƒkr4||kr4| j jƒ  | j|ƒ d S )Nr/   ÚddÚdtÚlir   r   ÚpÚrpÚrtr1   )rd   re   rf   r   r   rg   rh   ri   )r;   r   Ú	frozensetrN   ÚgenerateImpliedEndTags)r   Úexcluder   r   r   r   rk   g  s
    
z"TreeBuilder.generateImpliedEndTagsc             C   s   | j S )zReturn the final tree)r?   )r   r   r   r   ÚgetDocumentq  s    zTreeBuilder.getDocumentc             C   s   | j ƒ }| jd j|ƒ |S )zReturn the final fragmentr   )ÚfragmentClassr;   r(   )r   Zfragmentr   r   r   ÚgetFragmentu  s    zTreeBuilder.getFragmentc             C   s   t ‚dS )zzSerialize the subtree of node in the format required by unit tests
        node - the node from which to start serializingN)r!   )r   r"   r   r   r   ÚtestSerializer|  s    zTreeBuilder.testSerializer)N)N)N)N)r+   r,   r-   Ú__doc__r>   r\   rY   rW   rn   r   r:   rF   rM   rO   rQ   rT   rX   rZ   rR   r^   ra   Úpropertyr=   r`   r_   r&   rb   rk   rm   ro   rp   r   r   r   r   r8   z   s6   
.
	




r8   )Z
__future__r   r   r   Zpip._vendor.sixr   Z	constantsr   r   r	   r2   rj   ÚsetrB   Úobjectr   r   r.   r8   r   r   r   r   Ú<module>   s   
K