o
    i                 
   @  s  U d Z ddlmZ dZddlZddlZddlZddlZddlZddl	m
Z
 dZerddlmZmZmZmZmZ ddlmZ dd	lmZmZmZmZmZmZ dd
lmZ ddlmZ ddlm Z  ddl!m"Z"m#Z# ddl$m%Z% e&de&d B  Z'de(d< ed Z)e&e'e)f Z*de(d< e&e*df Z+de(d< e,ej-e, B Z.de(d< 	 ee,ee/gdf Z0de(d< G dd dZ1G dd de1e,Z2G dd de1Z3G dd dZ4G d d! d!Z5G d"d# d#Z6G d$d% d%Z7G d&d' d'Z8G d(d) d)e8Z9G d*d+ d+e8Z:G d,d- d-e8Z;G d.d/ d/e8Z<G d0d1 d1Z=G d2d3 d3Z>G d4d5 d5Z?G d6d7 d7Z@G d8d9 d9e<e@ZAG d:d; d;ZBG d<d= d=ZCG d>d? d?ZDG d@dA dAeCZEG dBdC dCeCZFG dDdE dEZGG dFdG dGe3ZHG dHdI dIeHZIG dJdK dKeHZJG dLdM dMe>e3ZKG dNdO dOe>e3ZLG dPdQ dQeGe@e6eHZMG dRdS dSeGe@e6eHZNG dTdU dUe@e6e3ZOG dVdW dWe6e3ZPG dXdY dYe@e6e3ZQG dZd[ d[e6e3ZRG d\d] d]e5e3ZSG d^d_ d_e5e3ZTG d`da dae5e3ZUeMdbfeNdcfe8eSeTeRfddfeUeRfddffeU_VG dedf dfe4e3ZWG dgdh dhe7eHZXG didj dje7eHZYG dkdl dle7eIZZG dmdn dne7eHZ[G dodp dpe7eHZ\G dqdr dre7eHZ]G dsdt dte7eHZ^G dudv dve7eHZ_G dwdx dxe7eHZ`G dydz dze7e3ZaG d{d| d|e;eHZbG d}d~ d~eGe;eHZcG dd de;e3ZdG dd de;e3ZeG dd de=eHZfG dd de;e3ZgG dd de;e?eEeHZhG dd de=e3ZiG dd de:e3ZjG dd de:e3ZkG dd de=eHZlG dd de=eHZmG dd de=e3ZnG dd de=e3ZoG dd de:e3ZpG dd de=eHZqG dd de=e3ZrG dd de=e7e3ZsG dd de:e3ZtG dd de=eJZuG dd de=eJZvG dd de=e3ZwG dd de=e3ZxG dd de=e3ZyG dd de=e3ZzG dd de:e3Z{G dd de;eIZ|G dd de;eIZ}G dd de;eIeJZ~G dd de=eHZG dd de;e3Zeefdffe_VG dd de9e3ZG dd de9e3ZG dd de9e3ZG dd de9e3ZG ddÄ de9e3ZG ddń de9e3ZG ddǄ de9e3ZG ddɄ de9e3ZG dd˄ de9e3ZG dd̈́ de9e3ZG ddτ de=eJZG ddф de;eDe3eBeFZG ddӄ de;eDe3eBeFZG ddՄ de;e?e3ZG ddׄ de=eHZG ddل de=e3ZG ddۄ de;e3ZG dd݄ de=e3ZG dd߄ de=e3ZG dd de=e3ZG dd de=e3ZG dd de=e3ZG dd de=e3ZG dd de;e3ZG dd deAeIeJZG dd deAeHZG dd deAe?eHeFZG dd de<eDe@e3ZG dd deAe3ZG dd de<e?e@eIeJZG dd de?eHZG dd de?eHZG dd de?eHZG dd de?eHZG dd de?eHZG d d de?eHZG dd de?eHZG dd de?eHZG dd de?eHZG dd	 d	e?eHZG d
d de?eEeJZG dd de?eEeJZG dd de?eHZG dd de?eJZG dd de?eHZd Zde(d< 	 G dd dZG dd deZG dd deZdd d!Zdd"d#Zdd$d%Zdd&d'Zee G d(d) d)eZG d*d+ d+eZG d,d- d-eZG d.d/ d/eZG d0d1 d1eZG d2d3 d3eZG d4d5 d5eZG d6d7 d7eZG d8d9 d9eZ		ddd?d@Zd dBdCZeĐdDZŐdEe(dF< eĐdGZƐdEe(dH< i dIdJdKdLdMdNdOdPdQdRdSdTdUdVdWdVdXdYdZdLd[d\d]d^d_dRd`dadbdcdddTdedTi dfdgdhdidjdkdldidmdRdndadodTdpdqdrdYdsdtdudidvdwdxdqdydzd{d|d}dgZǐd~e(d< ddddddZȐd~e(d< dddZɐdddZʐdddZːdddZ̐dddZ͐dddZΐddddZϐdddZАdddZѐdddZҐd	ddZӐd
ddZԐdddZՐdddZ֐dddZאdddZi de,de,deؓde,deғde,deғde,deՓdeՓdeٓdeٓdeؓdeԓde,de,deАdƐdǐdi deדdeАdʐdːd̐d͐d΃de,deАdѐdҐdӐdԐdՐdփdeӓde,deғde,deٓdeٓdeؓdeАdސdߐdde,deٓdeٓde˓deדi deՓdeՓdeؓde,deѓde˓de,deؓdeؓdeٓde,de,deٓdeؓde,dQe,deՓe,eАdѐdd҃eeАdddZڐde(d< dS (  a~  
Docutils document tree element class library.

The relationships and semantics of elements and attributes is documented in
`The Docutils Document Tree`__.

Classes in CamelCase are abstract base classes or auxiliary classes. The one
exception is `Text`, for a text (PCDATA) node; uppercase is used to
differentiate from element classes.  Classes in lower_case_with_underscores
are element classes, matching the XML element generic identifiers in the DTD_.

The position of each node (the level at which it can occur) is significant and
is represented by abstract base classes (`Root`, `Structural`, `Body`,
`Inline`, etc.).  Certain transformations will be easier because we can use
``isinstance(node, base_class)`` to determine the position of the node in the
hierarchy.

__ https://docutils.sourceforge.io/docs/ref/doctree.html
.. _DTD: https://docutils.sourceforge.io/docs/ref/docutils.dtd
    )annotationsreStructuredTextN)CounterF)CallableIterableIteratorMappingSequence)
ModuleType)AnyClassVarFinalLiteralSelfSupportsIndex)	TypeAlias)minidom)Values)Transformer	Transform)ReporterElement)r   .r   _ContentModelCategory).?+*_ContentModelItem._ContentModelTupleStrPath
_UpdateFunc                   @  sF  e Zd ZU dZdZded< 	 ded< 	 dZded< 	 dZd	ed
< 	 ded< 	 dZded< e	dQddZ
e
jdRddZ
dSddZ	dTdUddZdVdWd#d$ZdXd&d'ZdXd(d)ZdYd*d+ZdZd,d-Zd[d1d2Zd[d3d4Zd\d8d9Zd]d:d;Z		<	<	=	=d^d_dDdEZ		<	<	=	=d^d`dGdHZ		=	<	=	=dadbdJdKZdcdddMdNZdZdOdPZdS )eNodez0Abstract base class of nodes in a document tree.NElement | Noneparentr	   childrenStrPath | Nonesource
int | Nonelinestrtagnamedocument | None	_documentreturnc                 C  s&   z| j p| jjW S  ty   Y dS w )zJReturn the `document` root node of the tree containing this Node.
        N)r,   r#   documentAttributeErrorself r2   T/var/www/html/karishye-ai-python/venv/lib/python3.10/site-packages/docutils/nodes.pyr.   `   s
   zNode.documentvaluer.   Nonec                 C  
   || _ d S N)r,   )r1   r4   r2   r2   r3   r.   i   s   
Literal[True]c                 C     dS )a   
        Node instances are always true, even if they're empty.  A node is more
        than a simple container.  Its boolean "truth" does not depend on
        having one or more subnodes in the doctree.

        Use `len()` to check node length.
        Tr2   r0   r2   r2   r3   __bool__m   s   zNode.__bool__domModuleType | None1minidom.Document | minidom.Element | minidom.Textc                 C  s,   |du rddl m  m} | }| |S )z6Return a DOM **fragment** representation of this Node.Nr   )xml.dom.minidomr;   r   Document	_dom_noder1   r;   domrootr2   r2   r3   asdomw   s   
z
Node.asdom    r   indentlevelintc                 C     t )zs
        Return an indented pseudo-XML representation, for test purposes.

        Override in subclasses.
        NotImplementedError)r1   rE   rF   r2   r2   r3   pformat   s   zNode.pformatr   c                 C  rH   )zReturn a copy of self.rI   r0   r2   r2   r3   copy      z	Node.copyc                 C  rH   )z3Return a deep copy of self (also copying children).rI   r0   r2   r2   r3   deepcopy   rM   zNode.deepcopyc                 C  rH   )z,Return a string representation of this Node.rI   r0   r2   r2   r3   astext   rM   zNode.astextc                 C  sH   | |_ | jr | j|_|jd u r| jj|_|jd u r"| jj|_d S d S d S r7   )r#   r.   r&   current_sourcer(   current_liner1   childr2   r2   r3   setup_child   s   


zNode.setup_childvisitorNodeVisitorboolc              	   C  s   d}|j jd| jj  zGz||  W n ttfy#   | Y W S  ty+   Y nw | j	}z|dd D ]}|
|rAd} nq6W W |S W W |S  tyT   Y W |S w  ty`   d}Y |S w )a  
        Traverse a tree of `Node` objects, calling the
        `dispatch_visit()` method of `visitor` when entering each
        node.  (The `walkabout()` method is similar, except it also
        calls the `dispatch_departure()` method before exiting each
        node.)

        This tree traversal supports limited in-place tree
        modifications.  Replacing one node with one or more nodes is
        OK, as is removing an element.  However, if the node removed
        or replaced occurs after the current node, the old node will
        still be traversed, and any new nodes will not.

        Within ``visit`` methods (and ``depart`` methods for
        `walkabout()`), `TreePruningException` subclasses may be raised
        (`SkipChildren`, `SkipSiblings`, `SkipNode`, `SkipDeparture`).

        Parameter `visitor`: A `NodeVisitor` object, containing a
        ``visit`` implementation for each `Node` subclass encountered.

        Return true if we should stop the traversal.
        Fz6docutils.nodes.Node.walk calling dispatch_visit for %sNT)r.   reporterdebug	__class____name__dispatch_visitSkipChildrenSkipNodeSkipDeparturer$   walkSkipSiblingsStopTraversal)r1   rU   stopr$   rS   r2   r2   r3   r`      sB   

z	Node.walkc                 C  s   d}d}|j jd| jj  zAz||  W n ty#   | Y W S  ty-   d}Y nw | j}z|dd D ]}|	|rCd} nq8W n	 t
yN   Y nw W n tyY   Y n tyc   d}Y nw |rv|j jd| jj  ||  |S )a  
        Perform a tree traversal similarly to `Node.walk()` (which
        see), except also call the `dispatch_departure()` method
        before exiting each node.

        Parameter `visitor`: A `NodeVisitor` object, containing a
        ``visit`` and ``depart`` implementation for each `Node`
        subclass encountered.

        Return true if we should stop the traversal.
        TFz;docutils.nodes.Node.walkabout calling dispatch_visit for %sNz?docutils.nodes.Node.walkabout calling dispatch_departure for %s)r.   rX   rY   rZ   r[   r\   r^   r_   r$   	walkaboutra   r]   rb   dispatch_departure)r1   rU   call_departrc   r$   rS   r2   r2   r3   rd      sP   


zNode.walkaboutclstyper   c                 c  s2    t | |r	| V  | jD ]
}||E dH  qdS )z3Return iterator that only supports instance checks.N)
isinstancer$   _fast_findall)r1   rg   rS   r2   r2   r3   rj      s   

zNode._fast_findallc                 c  s&    | V  | j D ]	}| E dH  qdS )z3Return iterator that doesn't check for a condition.N)r$   _superfast_findallrR   r2   r2   r3   rk      s
   
zNode._superfast_findallTF	condition$type | Callable[[Node], bool] | Noneinclude_selfdescendsiblingsascendc                 c  sR   |rd}|r'|r'|s'|du r|   E dH  dS t|tr'| |E dH  dS t|tr4|}|fdd}|rA|du s>|| rA| V  |rZt| jrZ| D ]}|j|dddddE dH  qJ|s^|r| }|jr|j|}	|j|	 |ur|j||	d }	|j|	 |usp|j|	d d D ]}
|
j|d|dddE dH  q|sdS |j}|jscdS dS dS )a  
        Return an iterator yielding nodes following `self`:

        * self (if `include_self` is true)
        * all descendants in tree traversal order (if `descend` is true)
        * the following siblings (if `siblings` is true) and their
          descendants (if also `descend` is true)
        * the following siblings of the parent (if `ascend` is true) and
          their descendants (if also `descend` is true), and so on.

        If `condition` is not None, the iterator yields only nodes
        for which ``condition(node)`` is true.  If `condition` is a
        type ``cls``, it is equivalent to a function consisting
        of ``return isinstance(node, cls)``.

        If `ascend` is true, assume `siblings` to be true as well.

        If the tree structure is modified during iteration, the result
        is undefined.

        For example, given the following tree::

            <paragraph>
                <emphasis>      <--- emphasis.traverse() and
                    <strong>    <--- strong.traverse() are called.
                        Foo
                    Bar
                <reference name="Baz" refid="baz">
                    Baz

        Then tuple(emphasis.traverse()) equals ::

            (<emphasis>, <strong>, <#text: Foo>, <#text: Bar>)

        and list(strong.traverse(ascend=True) equals ::

            [<strong>, <#text: Foo>, <#text: Bar>, <reference>, <#text: Baz>]
        TNc                 S  s
   t | |S r7   )ri   )node
node_classr2   r2   r3   rl   E     
zNode.findall.<locals>.conditionF)rl   rn   ro   rp   rq      )	rk   ri   rh   rj   lenr$   findallr#   index)r1   rl   rn   ro   rp   rq   rs   rS   rr   rx   siblingr2   r2   r3   rw     sP   -


zNode.findalllistc                 C  s&   t jdtdd t| |||||S )zyReturn list of nodes following `self`.

        For looping, Node.findall() is faster and more memory efficient.
        z5nodes.Node.traverse() is obsoleted by Node.findall().   
stacklevel)warningswarnDeprecationWarningrz   rw   r1   rl   rn   ro   rp   rq   r2   r2   r3   traverse`  s   zNode.traverseNode | Nonec                 C  s.   zt | |||||W S  ty   Y dS w )z
        Return the first node in the iterator returned by findall(),
        or None if the iterable is empty.

        Parameter list is the same as of `findall()`.  Note that `include_self`
        defaults to False, though.
        N)nextrw   StopIterationr   r2   r2   r3   	next_nodeq  s   
zNode.next_node	recursivec                 C  r9   )z{Raise ValidationError if this node is not valid.

        Override in subclasses that define validity constraints.
        Nr2   )r1   r   r2   r2   r3   validate      zNode.validatec                 C  r9   )a  Hook for additional checks of the parent's content model.

        Raise ValidationError, if `self` is at an invalid position.

        Override in subclasses with complex validity constraints. See
        `subtitle.validate_position()` and `transition.validate_position()`.
        Nr2   r0   r2   r2   r3   validate_position  r   zNode.validate_position)r-   r+   )r4   r.   r-   r5   )r-   r8   r7   )r;   r<   r-   r=   rD   r   rE   r)   rF   rG   r-   r)   r-   r   r-   r)   r-   r5   )rU   rV   r-   rW   )rg   rh   r-   r   )r-   r   )NTTFF)rl   rm   rn   rW   ro   rW   rp   rW   rq   rW   r-   r   )rl   rm   rn   rW   ro   rW   rp   rW   rq   rW   r-   rz   )NFTFF)rl   rm   rn   rW   ro   rW   rp   rW   rq   rW   r-   r   Tr   rW   r-   r5   )r[   
__module____qualname____doc__r#   __annotations__r&   r(   r,   propertyr.   setterr:   rC   rK   rL   rN   rO   rT   r`   rd   rj   rk   rw   r   r   r   r   r2   r2   r2   r3   r!   I   sb   
 





	
.
+

Yr!   c                   @  s   e Zd ZU dZdZded< dZded< 	 d.d/ddZd0d1ddZd2ddZ	d2ddZ
d3ddZd4ddZd4d d!Zd5d6d&d'Zd.d7d*d+Zd.d7d,d-ZdS )8Texta  
    Instances are terminal nodes (leaves) containing text only; no child
    nodes or attributes.  Initialize by passing a string to the constructor.

    Access the raw (null-escaped) text with ``str(<instance>)``
    and unescaped text with ``<instance>.astext()``.
    z#textr   r*   r2   r$   Ndatar)   	rawsourcer5   r-   r   c                 C  s6   t |tr	td|durtjdtdd t| |S )zuAssert that `data` is not an array of bytes
        and warn if the deprecated `rawsource` argument is used.
        zexpecting str data, not bytesNz_nodes.Text: initialization argument "rawsource" is ignored and will be removed in Docutils 2.0.r{   r|   )ri   bytes	TypeErrorr~   r   r   r)   __new__)rg   r   r   r2   r2   r3   r     s   
zText.__new__   maxlenrG   c                 C  s6   | }t ||kr|d |d  d }d| jt|f S )N    ...z<%s: %r>)rv   r*   r)   )r1   r   r   r2   r2   r3   	shortrepr  s   zText.shortreprc                 C  s   | j ddS )ND   )r   )r   r0   r2   r2   r3   __repr__     zText.__repr__c                 C  s   t t| S r7   )r)   unescaper0   r2   r2   r3   rO     r   zText.astextrB   minidom.Documentminidom.Textc                 C  s   | t| S r7   )createTextNoder)   )r1   rB   r2   r2   r3   r@        zText._dom_nodec                 C  s   |  t| S r7   )rZ   r)   r0   r2   r2   r3   rL     r   z	Text.copyc                 C  s   |   S r7   )rL   r0   r2   r2   r3   rN     s   zText.deepcopyrD   r   rE   rF   c                   s   z(| j jjr'd  df } fdd| dD }d|g|R d W S W n	 ty1   Y nw     fdd|   D }|sGd	S d|d S )
Nz%s%sz<#text>c                 3  s$    | ]} d   t | V  qdS ru   N)repr.0r(   rE   rF   r2   r3   	<genexpr>  s    zText.pformat.<locals>.<genexpr>T
c                   s   g | ]} | qS r2   r2   r   )rE   r2   r3   
<listcomp>      z Text.pformat.<locals>.<listcomp> )r.   settingsdetailed
splitlinesjoinr/   rO   )r1   rE   rF   taglinesr2   r   r3   rK     s    
zText.pformatchars
str | Nonec                 C     |  t| |S r7   )rZ   r)   rstripr1   r   r2   r2   r3   r        zText.rstripc                 C  r   r7   )rZ   r)   lstripr   r2   r2   r3   r     r   zText.lstripr7   )r   r)   r   r5   r-   r   )r   )r   rG   r-   r)   r   )rB   r   r-   r   r   r   r   )r   r   r-   r   )r[   r   r   r   r*   r   r$   r   r   r   rO   r@   rL   rN   rK   r   r   r2   r2   r2   r3   r     s   
 




r   c                   @  sZ  e Zd ZU dZdZded< 	 ed Zded< 	 eZded< 	 eZded< 	 eZ	ded	< 	 d
Z
ded< 	 dZded< 	 dZded< 	 dZded< 	 	ddddZdd d!Zdd"d#Zdd$d%Zdd&d'Zddd*d+Zdd,d-Zdd.d/Zdd1d2Zdd4d5Zdd8d9Zdd:d;Zdd<d=Zdd@dAZddBdCZddEdFZddGdHZddJdKZddMdNZ dddQdRZ!ddTdUZ"ddVdWZ#dddXdYZ$e"Z%ddd[d\Z&dd]d^Z'ddadbZ(ddedfZ)dddidjZ*ddkdlZ+dme,j-fddpdqZ.drds Z/ddudvZ0ddwdxZ1dd{d|Z2dddZ3dddZ4ddddZ5	ddddZ6dddZ7dddZ8dddZ9e9ddfdddZ:		ddddZ;		ddddZ<		ddddZ=	ddddZ>dddZ?dddZ@dddZAdme,j-fdddZBdme,j-fdddZCddddZDdddZEdddZF		ddddZGeHdddZIeHdddZJdddZK		ddddƄZLdddʄZMdddd̈́ZNdS )r   aV  
    `Element` is the superclass to all specific elements.

    Elements contain attributes and child nodes.
    They can be described as a cross between a list and a dictionary.

    Elements emulate dictionaries for external [#]_ attributes, indexing by
    attribute name (a string). To set the attribute 'att' to 'value', do::

        element['att'] = 'value'

    .. [#] External attributes correspond to the XML element attributes.
       From its `Node` superclass, Element also inherits "internal"
       class attributes that are accessed using the standard syntax, e.g.
       ``element.parent``.

    There are two special attributes: 'ids' and 'names'.  Both are
    lists of unique identifiers: 'ids' conform to the regular expression
    ``[a-z](-?[a-z0-9]+)*`` (see the make_id() function for rationale and
    details). 'names' serve as user-friendly interfaces to IDs; they are
    case- and whitespace-normalized (see the fully_normalize_name() function).

    Elements emulate lists for child nodes (element nodes and/or text
    nodes), indexing by integer.  To get the first child node, use::

        element[0]

    to iterate over the child nodes (without descending), use::

        for child in element:
            ...

    Elements may be constructed using the ``+=`` operator.  To add one new
    child node to element, do::

        element += node

    This is equivalent to ``element.append(node)``.

    To add a list of multiple child nodes at once, use the same ``+=``
    operator::

        element += [node1, node2]

    This is equivalent to ``element.extend([node1, node2])``.
    )idsclassesnamesdupnamesr   list_attributes)r&   valid_attributescommon_attributesknown_attributesbasic_attributesbackrefslocal_attributesr2   zClassVar[_ContentModelTuple]content_modelNr   r*   z

child_text_separatorr   r   r)   
attributesr   r-   r5   c                 O  s   || _ 	 t|trtdg | _	 | | i | _	 | jD ]}g | j|< q| D ]\}}|	 }|| jv r@|d d  | j|< q)|| j|< q)| j
d u rR| jj| _
d S d S )Nz,First argument "rawsource" must be a string.)r   ri   r   r   r$   extendr   r   itemslowerr*   rZ   r[   )r1   r   r$   r   attr4   r2   r2   r3   __init__F  s&   




zElement.__init__rB   r   minidom.Elementc                 C  sl   | | j}|  D ]\}}t|trddd |D }||d|  q
| jD ]
}||	| q)|S )N c                 s  s    | ]
}t d |f V  qdS )%sNserial_escaper   vr2   r2   r3   r   p  s    z$Element._dom_node.<locals>.<genexpr>r   )
createElementr*   attlistri   rz   r   setAttributer$   appendChildr@   )r1   rB   element	attributer4   rS   r2   r2   r3   r@   l  s   

zElement._dom_nodec                 C  sl   d}| j D ]}|| 7 }t|dkr|d d d } nq| d r/d| jd| d |f S d| j|f S )	Nr   <   8   r   r   z<%s "%s": %s>; z<%s: %s>)r$   r   rv   r*   r   )r1   r   cr2   r2   r3   r   v  s   
zElement.__repr__c                 C  s*   | d rd| j d| d f S d| j  S )Nr   z<%s "%s"...>r   z<%s...>)r*   r   r0   r2   r2   r3   r     s   
zElement.shortreprc                 C  s6   | j rd|  ddd | j D |  f S |  S )Nz%s%s%sr   c                 s  s    | ]}t |V  qd S r7   )r)   r   r   r2   r2   r3   r     s    z"Element.__str__.<locals>.<genexpr>)r$   starttagr   endtagemptytagr0   r2   r2   r3   __str__  s   zElement.__str__	quoteattrCallable[[str], str] | Nonec                 C  s   |d u rt }| jg}|  D ]>\}}|d u r|d|  qt|tr)tt|}t|tr;dd |D }d	|}nt|}||}|d||f  qdd	| S )Nz	%s="True"c                 S  s   g | ]	}t d |f qS )r   r   r   r2   r2   r3   r     s    z$Element.starttag.<locals>.<listcomp>r   z%s=%sz<%s>)
pseudo_quoteattrr*   r   appendri   rW   r)   rG   rz   r   )r1   r   partsnamer4   valuesr2   r2   r3   r     s    

zElement.starttagc                 C  s
   d| j  S )Nz</%s>)r*   r0   r2   r2   r3   r     rt   zElement.endtagc                 C  s*   dd |   D }dd| jg|R  S )Nc                 s  s     | ]\}}d ||f V  qdS )z%s="%s"Nr2   )r   nr   r2   r2   r3   r         z#Element.emptytag.<locals>.<genexpr>z<%s/>r   )r   r   r*   )r1   r   r2   r2   r3   r     s   zElement.emptytagrG   c                 C  s
   t | jS r7   )rv   r$   r0   r2   r2   r3   __len__  rt   zElement.__len__rW   c                 C  s   t |tr
|| jv S || jv S r7   )ri   r)   r   r$   r1   keyr2   r2   r3   __contains__  s   


zElement.__contains__r   str | int | slicec                 C  s^   t |tr
| j| S t |tr| j| S t |tr+|jdv s"J d| j|j|j S t	dNNru   cannot handle slice with stridezFelement index must be an integer, a slice, or an attribute name string
ri   r)   r   rG   r$   slicestepstartrc   r   r   r2   r2   r3   __getitem__  s   




zElement.__getitem__c                 C  s   t |tr|| jt|< d S t |tr| | || j|< d S t |trB|jdv s-J d|D ]}| | q/|| j|j|j	< d S t
dr   )ri   r)   r   rG   rT   r$   r   r   r   rc   r   )r1   r   itemrr   r2   r2   r3   __setitem__  s   



zElement.__setitem__c                 C  sd   t |tr| j|= d S t |tr| j|= d S t |tr.|jdv s$J d| j|j|j= d S t	d)Nr   r   zMelement index must be an integer, a simple slice, or an attribute name stringr   r   r2   r2   r3   __delitem__  s   


zElement.__delitem__otherrz   c                 C  s
   | j | S r7   r$   r1   r  r2   r2   r3   __add__  rt   zElement.__add__c                 C  s
   || j  S r7   r  r  r2   r2   r3   __radd__  rt   zElement.__radd__r   c                 C  s.   t |tr| | | S |dur| | | S )z4Append a node or a list of nodes to `self.children`.N)ri   r!   r   r   r  r2   r2   r3   __iadd__  s   


zElement.__iadd__c                 C  s   | j dd | jD S )Nc                 S     g | ]}|  qS r2   )rO   r   rS   r2   r2   r3   r     r   z"Element.astext.<locals>.<listcomp>)r   r   r$   r0   r2   r2   r3   rO     s   zElement.astextdict[str, Any]c                   s    fdd j  D }|S )Nc                   s    i | ]\}}  |r||qS r2   )is_not_default)r   r   r4   r0   r2   r3   
<dictcomp>  s    z2Element.non_default_attributes.<locals>.<dictcomp>)r   r   )r1   attsr2   r0   r3   non_default_attributes  s   zElement.non_default_attributeslist[tuple[str, Any]]c                 C  s   t |   S r7   )sortedr  r   r0   r2   r2   r3   r        zElement.attlistfailobj
Any | Nonec                 C     | j ||S r7   )r   getr1   r   r  r2   r2   r3   r    r   zElement.getattrc                 C  
   || j v S r7   r   r1   r  r2   r2   r3   hasattr  rt   zElement.hasattrc                 C  s   || j v r| j |= d S d S r7   r  r  r2   r2   r3   delattr  s   
zElement.delattrc                 C  r  r7   )r   
setdefaultr  r2   r2   r3   r      r   zElement.setdefaultfallbackc                 C  sP   |  dg D ]}|dr|d  S qz| j|W S  ty'   | Y S w )zReturn node's language tag.

        Look iteratively in self and parents for a class argument
        starting with ``language-`` and return the remainder of it
        (which should be a `BCP49` language tag) or the `fallback`.
        r   z	language-)r  
startswithremoveprefixr#   get_language_coder/   )r1   r!  rg   r2   r2   r3   r$    s   
zElement.get_language_codec                 C     |  | | j| d S r7   )rT   r$   r   r1   r  r2   r2   r3   r        
zElement.appendr  r   c                 C  s   |D ]}|  | qd S r7   r   )r1   r  rr   r2   r2   r3   r     s   zElement.extendrx   r   c                 C  sB   t |tr| | | j|| d S |d ur|| ||< d S d S r7   )ri   r!   rT   r$   insert)r1   rx   r  r2   r2   r3   r)    s   

zElement.insertic                 C  s   | j |S r7   )r$   popr1   r+  r2   r2   r3   r,  #  r   zElement.popc                 C     | j | d S r7   )r$   remover&  r2   r2   r3   r/  &  r  zElement.remover   r   rc   c                 C  s   | j |||S r7   )r$   rx   )r1   r  r   rc   r2   r2   r3   rx   )  r  zElement.indexc                 C  s@   z| j | }W n
 ty   Y dS w |dkr| j |d  S dS )z*Return preceding sibling node or ``None``.Nr   ru   )r#   rx   r/   r-  r2   r2   r3   previous_sibling,  s   zElement.previous_siblinglist[section]c                 C  sB   g }| }|j durt|tr|| |j }|j dus	|  |S )a  Return the element's section anchestors.

        Return a list of all <section> elements that contain `self`
        (including `self` if it is a <section>) and have a parent node.

        List item ``[i]`` is the parent <section> of level i+1
        (1: section, 2: subsection, 3: subsubsection, ...).
        The length of the list is the element's section level.

        See `docutils.parsers.rst.states.RSTState.check_subsection()`
        for a usage example.

        Provisional. May be changed or removed without warning.
        N)r#   ri   sectionr   reverse)r1   sectionsrr   r2   r2   r3   section_hierarchy4  s   



zElement.section_hierarchyc                 C  s   | | g kr|| j v rdS dS )NFTr   r   r2   r2   r3   r  L  s   zElement.is_not_defaultdict_Mapping[str, Any] | Elementc                 C  s4   t |tr|j}| jD ]}| |||g  qdS )z
        Update basic attributes ('ids', 'names', 'classes',
        'dupnames', but not 'source') from node or dictionary `dict_`.

        Provisional.
        N)ri   r!   r   r   append_attr_listr  )r1   r7  r   r2   r2   r3   update_basic_attsR  s
   

zElement.update_basic_attsr   Iterable[Any]c                 C  s(   |D ]}|| | vr| |  | qdS )z
        For each element in values, if it does not exist in self[attr], append
        it.

        NOTE: Requires self[attr] and values to be sequence type and the
        former should specifically be a list.
        Nr(  )r1   r  r   r4   r2   r2   r3   r9  ^  s
   	zElement.append_attr_listr4   list[Any] | Anyc                 C  s>   t | |ts| | g| |< t |ts|g}| || dS )a  
        First, convert both self[attr] and value to a non-string sequence
        type; if either is not already a sequence, convert it to a list of one
        element.  Then call append_attr_list.

        NOTE: self[attr] and value both must not be None.
        N)ri   r  rz   r9  )r1   r  r4   r2   r2   r3   coerce_append_attr_listk  s
   

zElement.coerce_append_attr_listTforcec                 C  s"   |s	|  |du r|| |< dS dS )z
        If self[attr] does not exist or force is True or omitted, set
        self[attr] to value, otherwise do nothing.
        Nr  )r1   r  r4   r>  r2   r2   r3   replace_attr{  s   zElement.replace_attrreplacec                 C  s"   |  ||ur| || dS dS )a  
        If attr is an attribute of self, set self[attr] to
        [self[attr], value], otherwise set self[attr] to value.

        NOTE: replace is not used by this function and is kept only for
              compatibility with the other copy functions.
        N)r  r=  r1   r  r4   rA  r2   r2   r3   copy_attr_convert  s   	zElement.copy_attr_convertc                 C  sN   |  ||ur%t|  |tst|tr| || dS | ||| dS dS )a  
        If attr is an attribute of self and either self[attr] or value is a
        list, convert all non-sequence values to a sequence of 1 element and
        then concatenate the two sequence, setting the result to self[attr].
        If both self[attr] and value are non-sequences and replace is True or
        self[attr] is None, replace self[attr] with value. Otherwise, do
        nothing.
        N)r  ri   rz   r=  r@  rB  r2   r2   r3   copy_attr_coerce     	zElement.copy_attr_coercec                 C  sN   |  ||ur%t|  |trt|tr| || dS | ||| dS dS )aM  
        If attr is an attribute of self and both self[attr] and value are
        lists, concatenate the two sequences, setting the result to
        self[attr].  If either self[attr] or value are non-sequences and
        replace is True or self[attr] is None, replace self[attr] with value.
        Otherwise, do nothing.
        N)r  ri   rz   r9  r@  rB  r2   r2   r3   copy_attr_concatenate  rE  zElement.copy_attr_concatenatec                 C  s$   |  ||ur| ||| dS dS )zz
        If replace is True or self[attr] is None, replace self[attr] with
        value.  Otherwise, do nothing.
        N)r  r@  rB  r2   r2   r3   copy_attr_consistent  s   zElement.copy_attr_consistentF
update_funr    
and_sourcec                 C  sR   t |tr|j}|r| j}n| j}| | t||D ]}|| ||| | qdS )a.  
        Updates all attributes from node or dictionary `dict_`.

        Appends the basic attributes ('ids', 'names', 'classes',
        'dupnames', but not 'source') and then, for all other attributes in
        dict_, updates the same attribute in self.  When attributes with the
        same identifier appear in both self and dict_, the two values are
        merged based on the value of update_fun.  Generally, when replace is
        True, the values in self are replaced or merged with the values in
        dict_; otherwise, the values in self may be preserved or merged.  When
        and_source is True, the 'source' attribute is included in the copy.

        NOTE: When replace is False, and self contains a 'source' attribute,
              'source' is not replaced even when dict_ has a 'source'
              attribute, though it may still be merged into a list depending
              on the value of update_fun.
        NOTE: It is easier to call the update-specific methods then to pass
              the update_fun method to this function.
        N)ri   r!   r   is_not_list_attributeis_not_known_attributer:  filter)r1   r7  rH  rA  rI  
filter_funr   r2   r2   r3   update_all_atts  s   

zElement.update_all_attsc                 C     |  |tj|| dS )aC  
        Updates all attributes from node or dictionary `dict_`.

        Appends the basic attributes ('ids', 'names', 'classes',
        'dupnames', but not 'source') and then, for all other attributes in
        dict_, updates the same attribute in self.  When attributes with the
        same identifier appear in both self and dict_ and replace is True, the
        values in self are replaced with the values in dict_; otherwise, the
        values in self are preserved.  When and_source is True, the 'source'
        attribute is included in the copy.

        NOTE: When replace is False, and self contains a 'source' attribute,
              'source' is not replaced even when dict_ has a 'source'
              attribute, though it may still be merged into a list depending
              on the value of update_fun.
        N)rN  r   rG  r1   r7  rA  rI  r2   r2   r3   update_all_atts_consistantly  s   z$Element.update_all_atts_consistantlyc                 C  rO  )a  
        Updates all attributes from node or dictionary `dict_`.

        Appends the basic attributes ('ids', 'names', 'classes',
        'dupnames', but not 'source') and then, for all other attributes in
        dict_, updates the same attribute in self.  When attributes with the
        same identifier appear in both self and dict_ whose values aren't each
        lists and replace is True, the values in self are replaced with the
        values in dict_; if the values from self and dict_ for the given
        identifier are both of list type, then the two lists are concatenated
        and the result stored in self; otherwise, the values in self are
        preserved.  When and_source is True, the 'source' attribute is
        included in the copy.

        NOTE: When replace is False, and self contains a 'source' attribute,
              'source' is not replaced even when dict_ has a 'source'
              attribute, though it may still be merged into a list depending
              on the value of update_fun.
        N)rN  r   rF  rP  r2   r2   r3   update_all_atts_concatenating  s   z%Element.update_all_atts_concatenatingc                 C  rO  )a[  
        Updates all attributes from node or dictionary `dict_`.

        Appends the basic attributes ('ids', 'names', 'classes',
        'dupnames', but not 'source') and then, for all other attributes in
        dict_, updates the same attribute in self.  When attributes with the
        same identifier appear in both self and dict_ whose values are both
        not lists and replace is True, the values in self are replaced with
        the values in dict_; if either of the values from self and dict_ for
        the given identifier are of list type, then first any non-lists are
        converted to 1-element lists and then the two lists are concatenated
        and the result stored in self; otherwise, the values in self are
        preserved.  When and_source is True, the 'source' attribute is
        included in the copy.

        NOTE: When replace is False, and self contains a 'source' attribute,
              'source' is not replaced even when dict_ has a 'source'
              attribute, though it may still be merged into a list depending
              on the value of update_fun.
        N)rN  r   rD  rP  r2   r2   r3   update_all_atts_coercion  s   z Element.update_all_atts_coercionc                 C  s   | j |tj|d dS )a}  
        Updates all attributes from node or dictionary `dict_`.

        Appends the basic attributes ('ids', 'names', 'classes',
        'dupnames', but not 'source') and then, for all other attributes in
        dict_, updates the same attribute in self.  When attributes with the
        same identifier appear in both self and dict_ then first any non-lists
        are converted to 1-element lists and then the two lists are
        concatenated and the result stored in self; otherwise, the values in
        self are preserved.  When and_source is True, the 'source' attribute
        is included in the copy.

        NOTE: When replace is False, and self contains a 'source' attribute,
              'source' is not replaced even when dict_ has a 'source'
              attribute, though it may still be merged into a list depending
              on the value of update_fun.
        )rI  N)rN  r   rC  )r1   r7  rI  r2   r2   r3   update_all_atts_convert2  s   

zElement.update_all_atts_convertc                 C  s
   g | _ d S r7   r  r0   r2   r2   r3   clearJ  rt   zElement.clearc                 C  sJ   |  |}t|tr| | || |< dS |dur#|| ||d < dS dS )z8Replace one child `Node` with another child or children.Nru   )rx   ri   r!   rT   )r1   oldnewrx   r2   r2   r3   rA  M  s   


zElement.replacec                 C  s   |}t |tsz|d }W n ty   d}Y nw t |tr$||  n| jD ]}| | r7J d|| | f q'| j| | dS )z
        Replace `self` node with `new`, where `new` is a node or a
        list of nodes.

        Provisional: the handling of node attributes will be revised.
        r   NzLosing "%s" attribute: %s)ri   r!   
IndexErrorr   r:  r   r#   rA  )r1   rW  updater   r2   r2   r3   replace_selfV  s   



zElement.replace_self
childclassCtype[Element] | type[Text] | tuple[type[Element] | type[Text], ...]endr'   c                 C  sR   t |ts|f}t|tt| |D ]}|D ]}t | | |r%|    S qqdS )aM  
        Return the index of the first child whose class exactly matches.

        Parameters:

        - `childclass`: A `Node` subclass to search for, or a tuple of `Node`
          classes. If a tuple, any of the classes may match.
        - `start`: Initial index to check.
        - `end`: Initial index to *not* check.
        N)ri   tuplerangeminrv   r1   r[  r   r]  rx   r   r2   r2   r3   first_child_matching_classn  s   
z"Element.first_child_matching_classc                 C  sT   t |ts|f}t|tt| |D ]}|D ]}t | j| |r" nq|  S qdS )aI  
        Return the index of the first child whose class does *not* match.

        Parameters:

        - `childclass`: A `Node` subclass to skip, or a tuple of `Node`
          classes. If a tuple, none of the classes may match.
        - `start`: Initial index to check.
        - `end`: Initial index to *not* check.
        N)ri   r^  r_  r`  rv   r$   ra  r2   r2   r3   first_child_not_matching_class  s   
z&Element.first_child_not_matching_classrD   rE   rF   c                   s<   d  |   f } fdd| jD }d|g|R S )Nz%s%s
c                 3  s     | ]}|  d  V  qdS r   )rK   r   r   r2   r3   r     r   z"Element.pformat.<locals>.<genexpr>r   )r   r$   r   )r1   rE   rF   tagline	childrepsr2   r   r3   rK     s   zElement.pformatc                 C  s4   | j dd| ji| j}| j|_| j|_| j|_|S )Nr   r2   )rZ   r   r   r,   r&   r(   r1   objr2   r2   r3   rL     s
   zElement.copyc                 C  s"   |   }|dd | jD  |S )Nc                 S  r  r2   )rN   r  r2   r2   r3   r     r   z$Element.deepcopy.<locals>.<listcomp>)rL   r   r$   )r1   rL   r2   r2   r3   rN     s   zElement.deepcopyr   idc                 C  s^   d| _ t| di |}t| di |}|r |dusJ d|_ |r-|dus(J d|_ dS dS )zQNote that this Element has been referenced by its name
        `name` or id `id`.Texpect_referenced_by_nameexpect_referenced_by_idN)
referencedgetattrr  )r1   r   rh  by_nameby_idr2   r2   r3   note_referenced_by  s   
zElement.note_referenced_byc                 C  
   || j vS )z
        Returns True if and only if the given attribute is NOT one of the
        basic list attributes defined for all Elements.
        r6  rg   r  r2   r2   r3   rJ    s   
zElement.is_not_list_attributec                 C  rp  )u   
        Return True if `attr` is NOT defined for all Element instances.

        Provisional. May be removed in Docutils 2.0.
        )r   rq  r2   r2   r3   rK    s   
zElement.is_not_known_attributec                 C  s   g }| j  D ]P\}}|drq|| jvr)d| j}|d| d| d qzt| || j |< W q ttt	fyW } z|d| d| d|  W Y d}~qd}~ww |rkt
d	|   d
d| | ddS )zNormalize and validate element attributes.

        Convert string values to expected datatype.
        Normalize values.

        Raise `ValidationError` for invalid attributes or attribute values.

        Provisional.
        z	internal:", "zAttribute "z" not one of "".z" has invalid value "z".
  NElement z invalid:
  
  problematic_element)r   r   r"  r   r   r   ATTRIBUTE_VALIDATORS
ValueErrorr   KeyErrorValidationErrorr   )r1   messagesr   r4   vaer2   r2   r3   validate_attributes  s.   


zElement.validate_attributesmodel_ContentModelTuple | NoneelementsSequence | Nonec              
   C  s   |du r| j }|du r| j}t|}t|d}|D ]C\}}t||s1|dv r0t| |||dq|  |dv r?t|d}q|D ]}t||sJ nz|  W qA tyY   Y qAw d}q|du rcg S |g|S )al  Test compliance of `elements` with `model`.

        :model: content model description, default `self.content_model`,
        :elements: list of doctree elements, default `self.children`.

        Return list of children that do not fit in the model or raise
        `ValidationError` if the content does not comply with the `model`.

        Provisional.
        N)r   r   rv  )r   r   )	r   r$   iterr   ri   r{  _report_childr   r/   )r1   r  r  	ichildrenrS   category
quantifierr2   r2   r3   validate_content  s6   


zElement.validate_contentr  Element | Iterable[Element]c                 C  s   z|j }W n ty   ddd |D }Y nw d|   d}|d u r-| d| dS t|tr?| d| d	|  d
S | d| d|  dS )Nz> or <c                 s  s    | ]}|j V  qd S r7   )r[   r   r2   r2   r3   r   (  s    z(Element._report_child.<locals>.<genexpr>rt  z
 invalid:
z  Missing child of type <z>.z  Expecting child of type <z>, not text data "rs  z>, not r   )r[   r/   r   r   ri   r   rO   )r1   rS   r  _typemsgr2   r2   r3   r     s   

zElement._report_childr   c                 C  s   |    |  }|D ](}t|tr"td|   d|  d| dtd|   d|  d|d|r@| D ]
}|j|d q7dS dS )	a  Validate Docutils Document Tree element ("doctree").

        Raise ValidationError if there are violations.
        If `recursive` is True, validate also the element's descendants.

        See `The Docutils Document Tree`__ for details of the
        Docutils Document Model.

        __ https://docutils.sourceforge.io/docs/ref/doctree.html

        Provisional (work in progress).
        rt  z invalid:
  Spurious text: "rs  rv  z invalid:
  Child element z not allowed at this position.r   N)r  r  ri   r   r{  r   rO   r   )r1   r   leftover_childsrS   r2   r2   r3   r   2  s&   
zElement.validate)r   )r   r)   r   r   r-   r5   )rB   r   r-   r   r   r7   )r   r   r-   r)   )r-   rG   )r-   rW   )r   r   r-   r   r   )r   r   r-   r5   )r  rz   r-   rz   r   r-   r  )r-   r  )r   r)   r  r  r-   r   )r  r)   r-   rW   )r  r)   r-   r5   )r!  r)   r-   r)   )r  r   r-   r5   )rx   r   r-   r5   )r*  )r+  rG   )r   rG   rc   rG   r-   rG   )r-   r1  )r   r)   r-   rW   )r7  r8  r-   r5   )r  r)   r   r;  r-   r5   )r  r)   r4   r<  r-   r5   r   )r  r)   r4   r   r>  rW   r-   r5   )r  r)   r4   r   rA  rW   r-   r5   )
r7  r8  rH  r    rA  rW   rI  rW   r-   r5   )TF)r7  r8  rA  rW   rI  rW   r-   r5   )F)r7  r8  rI  rW   r-   r5   )r[  r\  r   rG   r]  rG   r-   r'   r   r   NN)r   r   rh  r   r-   r5   r  r  r  r  r-   rz   )r  r  r-   r)   r   )Or[   r   r   r   r   r   r   r   r   r   r   r   r*   r   r   r@   r   r   r   r   r   r   r   r   r  r  r  r  r	  r
  rO   r  r   r  r  r  r   has_keyr$  r   r   r)  r,  r/  sysmaxsizerx   r0  r5  r  r:  r9  r=  r@  rC  rD  rF  rG  rN  rQ  rR  rS  rT  rU  rA  rZ  rb  rc  rK   rL   rN   ro  classmethodrJ  rK  r  r  r  r   r2   r2   r2   r3   r     s   
 /
&































,


	



-c                   @     e Zd ZdZdS )Rootz'Element at the root of a document tree.Nr[   r   r   r   r2   r2   r2   r3   r  X      r  c                   @  r  )
Structuralzw`Structural elements`__.

    __ https://docutils.sourceforge.io/docs/ref/doctree.html
       #structural-elements
    Nr  r2   r2   r2   r3   r  \  r  r  c                   @  r  )SubStructuralz`Structural subelements`__ are children of `Structural` elements.

    Most Structural elements accept only specific `SubStructural` elements.

    __ https://docutils.sourceforge.io/docs/ref/doctree.html
       #structural-subelements
    Nr  r2   r2   r2   r3   r  d  r  r  c                   @  r  )Bibliographicz`Bibliographic Elements`__ (displayed document meta-data).

    __ https://docutils.sourceforge.io/docs/ref/doctree.html
       #bibliographic-elements
    Nr  r2   r2   r2   r3   r  n  r  r  c                   @  r  )Bodyzc`Body elements`__.

    __ https://docutils.sourceforge.io/docs/ref/doctree.html#body-elements
    Nr  r2   r2   r2   r3   r  v  r  r  c                   @  $   e Zd ZU dZedffZded< dS )
Admonitionz5Admonitions (distinctive and self-contained notices).r   r   r   Nr[   r   r   r   r  r   r   r2   r2   r2   r3   r  }     
 r  c                   @  r  )
SequentialzList-like body elements.Nr  r2   r2   r2   r3   r    r  r  c                   @  r  )GeneralzMiscellaneous body elements.Nr  r2   r2   r2   r3   r    r  r  c                   @  r  )SpecialzSpecial internal body elements.Nr  r2   r2   r2   r3   r    r  r  c                   @  r  )Partz`Body Subelements`__ always occur within specific parent elements.

    __ https://docutils.sourceforge.io/docs/ref/doctree.html#body-subelements
    Nr  r2   r2   r2   r3   r    r  r  c                   @  r  )
DecorativezPDecorative elements (`header` and `footer`).

    Children of `decoration`.
    r   r   r   Nr  r2   r2   r2   r3   r    s   
 r  c                   @  r  )InlinezJInline elements contain text data and possibly other inline elements.
    Nr  r2   r2   r2   r3   r    r  r  c                   @  r  )PreBibliographicz7Elements which may occur before Bibliographic Elements.Nr  r2   r2   r2   r3   r    r  r  c                   @  r  )	Invisiblez.Internal elements that don't appear in output.Nr  r2   r2   r2   r3   r    r  r  c                   @  r  )Labeledz(Contains a `label` as its first element.Nr  r2   r2   r2   r3   r    r  r  c                   @  s   e Zd ZU dZded< dS )
ResolvableFrW   resolvedN)r[   r   r   r  r   r2   r2   r2   r3   r    s   
 r  c                   @  s@   e Zd ZU dZejd Zded< ejd Zded< dddZdS )BackLinkablez6Mixin for Elements that accept a "backrefs" attribute.r   r   r   r   r1   r   refidr)   r-   r5   c                 C  s   | d  | d S )Nr   r(  )r1   r  r2   r2   r3   add_backref  r   zBackLinkable.add_backrefN)r1   r   r  r)   r-   r5   )	r[   r   r   r   r   r   r   r   r  r2   r2   r2   r3   r    s
   
 r  c                   @  r  )Referentialz8Elements holding a cross-reference (outgoing hyperlink).Nr  r2   r2   r2   r3   r    r  r  c                   @  s*   e Zd ZU dZdZded< dZded< dS )
Targetablez-Cross-reference targets (incoming hyperlink).r   rG   rk  Nr   indirect_reference_name)r[   r   r   r   rk  r   r  r2   r2   r2   r3   r    s
   
 r  c                   @  r  )Titularz/Title, sub-title, or informal heading (rubric).Nr  r2   r2   r2   r3   r    r  r  c                   @  sF   e Zd ZU dZeefdffZded< dZded< 	 		ddddZ	dS )TextElementa  
    An element which directly contains text.

    Its children are all `Text` or `Inline` subclass nodes.  You can
    check whether an element's context is inline simply by checking whether
    its immediate parent is a `TextElement` instance (including subclasses).
    This is handy for nodes like `image` that can appear both inline and as
    standalone body elements.

    If passing children to `__init__()`, make sure to set `text` to
    ``''`` or some other suitable value.
    r   r   r   r   r   r   r)   textr   r   r-   r5   c                 O  sJ   |rt |}tj| ||g|R i | d S tj| |g|R i | d S r7   )r   r   r   )r1   r   r  r$   r   textnoder2   r2   r3   r     s   
zTextElement.__init__Nr   r   r   r)   r  r)   r   r   r-   r5   )
r[   r   r   r   r   r  r   r   r   r   r2   r2   r2   r3   r    s   
 r  c                      s<   e Zd ZU dZejd Zded< 		dd fddZ  ZS )FixedTextElementz5An element which directly contains preformatted text.)	xml:spacer   r   r   r   r)   r  r   r   r-   r5   c                   s*   t  j||g|R i | d| jd< d S )Npreserver  )superr   r   )r1   r   r  r$   r   rZ   r2   r3   r     s   zFixedTextElement.__init__r  r  )	r[   r   r   r   r   r   r   r   __classcell__r2   r2   r  r3   r    s   
 r  c                   @  r  )PureTextElementz1An element which only contains text, no children.r   r   r   N)r[   r   r   r   r   r   r   r2   r2   r2   r3   r    r  r  c                   @     e Zd ZdS )headerNr[   r   r   r2   r2   r2   r3   r        r  c                   @  r  )footerNr  r2   r2   r2   r3   r    r  r  c                   @  $   e Zd ZU dZejd Zded< dS )titlezFTitle of `document`, `section`, `topic` and generic `admonition`.
    )autor  r   r   Nr[   r   r   r   r   r   r   r2   r2   r2   r3   r    s   
 r  c                   @     e Zd ZdZdddZdS )subtitlez1Sub-title of `document`, `section` and `sidebar`.r-   r5   c                 C  s8   | j r| j | dkrtd| j   d| ddS dS )z0Check position of subtitle: must follow a title.r   rt  z2 invalid:
  <subtitle> only allowed after <title>.rv  N)r#   rx   r{  r   r0   r2   r2   r3   r   "  s
   zsubtitle.validate_positionNr   r[   r   r   r   r   r2   r2   r2   r3   r    s    r  c                   @  r  )metaz;Container for "invisible" bibliographic data, or meta-data.)contentdir
http-equivlangmediar   schemer   r   Nr  r2   r2   r2   r3   r  *  r  r  c                   @  r  )docinfoz+Container for displayed document meta-data.r   r   r   N)r[   r   r   r   r  r   r   r2   r2   r2   r3   r  0  r  r  c                   @  s>   e Zd ZU dZedfedffZded< dddZdd
dZ	dS )
decorationz$Container for `header` and `footer`.r   r   r   r-   r  c                 C  s2   t | jrt| jd ts| dt  | jd S Nr   )rv   r$   ri   r  r)  r0   r2   r2   r3   
get_header=  s   
zdecoration.get_headerr  c                 C  s0   t | jrt| jd ts| t  | jd S )Nr*  )rv   r$   ri   r  r   r0   r2   r2   r3   
get_footerB  s   
zdecoration.get_footerN)r-   r  )r-   r  )
r[   r   r   r   r  r  r   r   r  r  r2   r2   r2   r3   r  6  s   
 
r  c                   @  r  )
transitionzTransitions__ are breaks between untitled text parts.

    __ https://docutils.sourceforge.io/docs/ref/doctree.html#transition
    r-   r5   c                 C  s   d| j   dg}|  }|du st|ttttfr |d | j 	| t
| j d kr2|d t|tr<|d t
|dkrKtd|| d	dS )
zCheck additional constraints on `transition` placement.

        A transition may not begin or end a section or document,
        nor may two transitions be immediately adjacent.
        rt  z	 invalid:Nz1<transition> may not begin a section or document.ru   z/<transition> may not end a section or document.z8<transition> may not directly follow another transition.ru  rv  )r#   r   r0  ri   r  r  r  r  r   rx   rv   r  r{  r   )r1   r|  predecessorr2   r2   r3   r   N  s&   


ztransition.validate_positionNr   r  r2   r2   r2   r3   r  H  s    r  c                   @  *   e Zd ZU dZedfedffZded< dS )topiczx
    Topics__ are non-recursive, mini-sections.

    __ https://docutils.sourceforge.io/docs/ref/doctree.html#topic
    r   r   r   r   N)r[   r   r   r   r  r  r   r   r2   r2   r2   r3   r  j  s   
 r  c                   @  s4   e Zd ZU dZedfedfeefdffZde	d< dS )sidebarz
    Sidebars__ are like parallel documents providing related material.

    A sidebar is typically offset by a border and "floats" to the side
    of the page

    __ https://docutils.sourceforge.io/docs/ref/doctree.html#sidebar
    r   r   r   r   N)
r[   r   r   r   r  r  r  r  r   r   r2   r2   r2   r3   r  t  s   
 
r  c                   @  r  )r2  zzDocument section__. The main unit of hierarchy.

    __ https://docutils.sourceforge.io/docs/ref/doctree.html#section
    Nr  r2   r2   r2   r3   r2    r  r2  r   r   r   c                
   @  s  e Zd ZU dZejd Zded< edfedfe	dfe
dfedfedfeeeefdfeefdffZded< dqddZdrddZdsdtddZ		dudvd"d#Z		$dwdxd(d)Zdyd+d,Zdzd-d.Z	dsd{d0d1Z	dsd{d2d3Zd|d4d5Zd|d6d7Zd}d8d9Zd}d:d;Zd~d=d>ZddAdBZ d~dCdDZ!ddEdFZ"d~dGdHZ#ddIdJZ$ddLdMZ%ddOdPZ&	dsddTdUZ'ddYdZZ(	dsdd^d_Z)ddbdcZ*ddddeZ+ddidjZ,ddldmZ-ddodpZ.dS )r.   z
    The document root element.

    Do not instantiate this class directly; use
    `docutils.utils.new_document()` instead.
    )r  r   r   r   r   r   r   r   rX   r   kwargsr   r-   r5   c                 O  s  t j| g|R i | d | _	 d | _	 || _	 || _	 g | _	 i | _	 i | _	 i | _		 i | _
	 i | _	 i | _	 i | _	 i | _	 i | _	 g | _	 g | _	 g | _	 g | _	 g | _	 g | _	 d| _	 d| _	 t | _	 g | _	 g | _	 dd l}|j| | _	 g | _ 	 d | _!	 | | _"d S )Nru   r   )#r   r   rP   rQ   r   rX   indirect_targetssubstitution_defssubstitution_namesrefnamesrefidsnameids	nametypesr   footnote_refscitation_refsautofootnotesautofootnote_refssymbol_footnotessymbol_footnote_refs	footnotes	citationsautofootnote_startsymbol_footnote_startr   
id_counterparse_messagestransform_messagesdocutils.transforms
transformsr   transformerinclude_logr  r,   )r1   r   rX   argsr  docutilsr2   r2   r3   r     sv   
zdocument.__init__r  c                 C  s   | j  }d|d< d|d< |S )zB
        Return dict with unpicklable references removed.
        NrX   r  )__dict__rL   )r1   stater2   r2   r3   __getstate__  s   
zdocument.__getstate__Nr;   r<   r   c                 C  s6   |du rddl m  m} | }|| | |S )z-Return a DOM representation of this document.Nr   )r>   r;   r   r?   r   r@   rA   r2   r2   r3   rC     s
   zdocument.asdomr   rr   r   msgnoder"   suggested_prefixr)   c              	   C  sr  |d r;|d D ]0}| j || | j | |ur8| jjd| d| j |   d|  |d}|d ur8||7 }q|S | jj}| jj}d}d}|d D ] }	|rZtd|	 d	d  }nt|	}|| }|rk|| j vrk n@qK|rx|	d
rx|d }
n|| }
|
	d
r|
d d  |pt|j
 d}
	 | j|
  d	7  < |
 | j|
  }|| j vrnq|d | || j |< |S )Nr   zDuplicate ID: "z
" used by z and 	base_noder   r   xru   %-r*  )r   r   rX   errorr   r   	id_prefixauto_id_prefixmake_idendswithr*   r  r   )r1   rr   r  r  rh  r  r  r  base_idr   prefixr2   r2   r3   set_id#  sV   



zdocument.set_idFrh  explicitrW   c                 C  sH   t |d D ]}|| jv r| ||||| q|| j|< || j|< qdS )a  
        Update the name/id mappings.

        `self.nameids` maps names to IDs. The value ``None`` indicates
        that the name is a "dupname" (i.e. there are already at least
        two targets with the same name and type).

        `self.nametypes` maps names to booleans representing
        hyperlink target type (True==explicit, False==implicit).

        The following state transition table shows how `self.nameids` items
        ("id") and `self.nametypes` items ("type") change with new input
        (a call to this method), and what actions are performed:

        ========  ====  ========  ====  ========  ======== =======  ======
         Input      Old State      New State            Action      Notes
        --------  --------------  --------------  ----------------  ------
        type      id    type      id    type      dupname  report
        ========  ====  ========  ====  ========  ======== =======  ======
        explicit                  new   explicit
        implicit                  new   implicit
        explicit  old   explicit  None  explicit  new,old  WARNING  [#ex]_
        implicit  old   explicit  old   explicit  new      INFO     [#ex]_
        explicit  old   implicit  new   explicit  old      INFO     [#ex]_
        implicit  old   implicit  None  implicit  new,old  INFO     [#ex]_
        explicit  None  explicit  None  explicit  new      WARNING
        implicit  None  explicit  None  explicit  new      INFO
        explicit  None  implicit  new   explicit
        implicit  None  implicit  None  implicit  new      INFO
        ========  ====  ========  ====  ========  ======== =======  ======

        .. [#] Do not clear the name-to-id map or invalidate the old target if
           both old and new targets refer to identical URIs or reference names.
           The new target is invalidated regardless.

        Provisional. There will be changes to prefer explicit reference names
        as base for an element's ID.
        r   N)r^  r  set_duplicate_name_idr  )r1   rr   rh  r  r
  r   r2   r2   r3   set_name_id_mapU  s   ,

zdocument.set_name_id_mapr   c                 C  s  | j | }| j| }| j|}d}	|p|| j|< |d urRd|v r*|d |dks7d|v rR|d |dkrRd}	|dpB|d}
d| d|
 d}t|| nT|r|rrd}	d	| d}t|| |d urqt|| d | j |< n4|| j |< |d urd}	d
| d}t|| nd}	d| d}t|| |d ur|st|| d | j |< |	r|g}t|trd|v rg }| jj|	|||d}|d ur||7 }z	|j	dd W d S  t
y   |  d |_Y d S w d S d S )Nr   refnamerefuriru   zDuplicate name "z" for external target "rs  r{   z!Duplicate explicit target name: "z,Target name overrides implicit target name "z!Duplicate implicit target name: ")r   r  Fr  )r  r  r   r  dupnameri   targetrX   system_messager   r{  r,  r#   )r1   rr   rh  r   r  r
  old_idold_explicitold_noderF   refsr   r  r2   r2   r3   r    sf   










	zdocument.set_duplicate_name_idc                 C  r  r7   )r  )r1   r   r2   r2   r3   has_name  rt   zdocument.has_namer  c                 C  "   |  ||}| j|||dd d S )NFr
  r	  r  r1   r  r  rh  r2   r2   r3   note_implicit_target  s   zdocument.note_implicit_targetc                 C  r  )NTr  r  r  r2   r2   r3   note_explicit_target  s   zdocument.note_explicit_targetc                 C     | j |d g | d S Nr  )r  r   r   r1   rr   r2   r2   r3   note_refname     zdocument.note_refnamec                 C  r  )Nr  )r  r   r   r   r2   r2   r3   
note_refid  r"  zdocument.note_refidc                 C  s&   | j | |d r| | d S d S )Nr   )r  r   r!  r1   r  r2   r2   r3   note_indirect_target  s   zdocument.note_indirect_targetc                 C     |  | d S r7   )r	  r$  r2   r2   r3   note_anonymous_target  r   zdocument.note_anonymous_targetfootnotec                 C  r%  r7   )r	  r  r   r1   r(  r2   r2   r3   note_autofootnote  r'  zdocument.note_autofootnoter  footnote_referencec                 C  r%  r7   )r	  r  r   r1   r  r2   r2   r3   note_autofootnote_ref  r'  zdocument.note_autofootnote_refc                 C  r%  r7   )r	  r  r   r)  r2   r2   r3   note_symbol_footnote  r'  zdocument.note_symbol_footnotec                 C  r%  r7   )r	  r  r   r,  r2   r2   r3   note_symbol_footnote_ref  r'  z!document.note_symbol_footnote_refc                 C  r%  r7   )r	  r  r   r)  r2   r2   r3   note_footnote  r'  zdocument.note_footnotec                 C  0   |  | | j|d g | | | d S r  )r	  r  r   r   r!  r,  r2   r2   r3   note_footnote_ref     
zdocument.note_footnote_refcitationc                 C  r.  r7   )r  r   )r1   r4  r2   r2   r3   note_citation   r  zdocument.note_citationcitation_referencec                 C  r1  r  )r	  r  r   r   r!  r,  r2   r2   r3   note_citation_ref  r3  zdocument.note_citation_refsubdefsubstitution_definitiondef_namec                 C  sf   t |}|| jv r%| jjd| |d}|d ur||7 }| j| }t|| || j|< || jt|< d S )Nz-Duplicate substitution definition name: "%s".r  )whitespace_normalize_namer  rX   r  r  r  fully_normalize_name)r1   r8  r:  r  r   r  oldnoder2   r2   r3   note_substitution_def  s   



zdocument.note_substitution_defsubrefsubstitution_referencer  c                 C  s   t ||d< d S r  r;  )r1   r?  r  r2   r2   r3   note_substitution_ref  s   zdocument.note_substitution_refpendingpriorityr'   c                 C  s   | j || d S r7   )r  add_pending)r1   rC  rD  r2   r2   r3   note_pending!     zdocument.note_pendingmessager  c                 C  r.  r7   )r  r   r1   rH  r2   r2   r3   note_parse_message%  r  zdocument.note_parse_messagec                 C  r.  r7   )r  r   rI  r2   r2   r3   note_transform_message(  r  zdocument.note_transform_messager&   r%   offsetc                 C  s0   |ot || _|d u r|| _d S |d | _d S r   )osfspathrP   rQ   )r1   r&   rL  r2   r2   r3   note_source+  s   
zdocument.note_sourcer   c                 C  s.   | j | j| jfi | j}| j|_| j|_|S r7   )rZ   r   rX   r   r&   r(   rf  r2   r2   r3   rL   5  s   zdocument.copyr  c                 C  sJ   | j s"t  | _ | ttf}|d u r| | j  | j S | || j  | j S r7   )r  rc  r  r  r   r)  )r1   rx   r2   r2   r3   get_decoration<  s   zdocument.get_decoration)r   r   rX   r   r  r   r-   r5   r  r7   )r;   r<   r-   r   Nr   )rr   r   r  r"   r  r)   r-   r)   )NF)
rr   r   rh  r)   r  r"   r
  rW   r-   r5   )rr   r   rh  r)   r   r)   r  r   r
  rW   r-   r5   )r   r)   r-   rW   )r  r   r  r"   r-   r5   )rr   r   r-   r5   )r  r  r-   r5   )r(  r(  r-   r5   )r  r+  r-   r5   )r4  r4  r-   r5   )r  r6  r-   r5   )r8  r9  r:  r)   r  r"   r-   r5   )r?  r@  r  r)   r-   r5   )rC  rC  rD  r'   r-   r5   )rH  r  r-   r5   )r&   r%   rL  r'   r-   r5   r   )r-   r  )/r[   r   r   r   r   r   r   r  r  r  r  r  r  r  r  r  r2  r   r   r  rC   r	  r  r  r  r  r  r!  r#  r%  r'  r*  r-  r.  r/  r0  r2  r5  r7  r>  rB  rF  rJ  rK  rO  rL   rP  r2   r2   r2   r3   r.     sb   
 


`	
5
4
?	

















r.   c                   @  r  )authorNr  r2   r2   r2   r3   rR  J  r  rR  c                   @  r  )organizationNr  r2   r2   r2   r3   rS  K  r  rS  c                   @  r  )addressNr  r2   r2   r2   r3   rT  L  r  rT  c                   @  r  )contactNr  r2   r2   r2   r3   rU  M  r  rU  c                   @  r  )versionNr  r2   r2   r2   r3   rV  N  r  rV  c                   @  r  )revisionNr  r2   r2   r2   r3   rW  O  r  rW  c                   @  r  )statusNr  r2   r2   r2   r3   rX  P  r  rX  c                   @  r  )dateNr  r2   r2   r2   r3   rY  Q  r  rY  c                   @  r  )	copyrightNr  r2   r2   r2   r3   rZ  R  r  rZ  c                      sN   e Zd ZU dZedfedfedfedffZde	d< 		dd fddZ
  ZS )authorszJContainer for author information for documents with multiple authors.
    r   r   r   r   Nr  r  r  r  r-   rz   c                   s$   t   }|rt  j|d}|s|S )zWRepeatedly test for children matching the content model.

        Provisional.
        )r  )r  r  )r1   r  r  relicsr  r2   r3   r  _  s
   
zauthors.validate_contentr  r  )r[   r   r   r   rR  rS  rT  rU  r   r   r  r  r2   r2   r  r3   r[  U  s   
 r[  c                   @  r  )	paragraphNr  r2   r2   r2   r3   r]  u  r  r]  c                   @  r  )rubricNr  r2   r2   r2   r3   r^  v  r  r^  c                   @      e Zd ZU edffZded< dS )compoundr   r   r   Nr[   r   r   r  r   r   r2   r2   r2   r3   r`  y     
 r`  c                   @  r_  )	containerr   r   r   Nra  r2   r2   r2   r3   rc  }  rb  rc  c                   @  r  )attributionz3Visible reference to the source of a `block_quote`.Nr  r2   r2   r2   r3   rd    r  rd  c                   @  r  )block_quotez2An extended quotation, set off from the main text.r   r   r   r   N)r[   r   r   r   r  rd  r   r   r2   r2   r2   r3   re    s   
 re  c                   @      e Zd ZU ejd Zded< dS )	reference)	anonymousr   r  r  r  r   r   Nr[   r   r   r   r   r   r2   r2   r2   r3   rg    rb  rg  c                   @  r_  )	list_itemr   r   r   Nra  r2   r2   r2   r3   rj    rb  rj  c                   @  2   e Zd ZU ejd Zded< edffZded< dS )bullet_list)bulletr   r   r   r   Nr[   r   r   r   r   r   rj  r   r2   r2   r2   r3   rl    s   
 rl  c                   @  rk  )enumerated_list)enumtyper  suffixr   r   r   r   r   Nrn  r2   r2   r2   r3   ro    s   
 ro  c                   @  r  )termNr  r2   r2   r2   r3   rr    r  rr  c                   @  r  )
classifierNr  r2   r2   r2   r3   rs    r  rs  c                   @  r  )
definitionz.Definition of a `term` in a `definition_list`.r   r   r   Nr  r2   r2   r2   r3   rt    r  rt  c                   @  s0   e Zd ZU edfeefdfedffZded< dS )definition_list_itemr   r   r   r   N)r[   r   r   rr  rs  rt  r   r   r2   r2   r2   r3   ru    s
   
 
ru  c                   @  r  )definition_listzList of terms and their definitions.

    Can be used for glossaries or dictionaries, to describe or
    classify things, for dialogues, or to itemize subtopics.
    r   r   r   N)r[   r   r   r   ru  r   r   r2   r2   r2   r3   rv       
 rv  c                   @  r  )
field_nameNr  r2   r2   r2   r3   rx    r  rx  c                   @  r_  )
field_bodyr   r   r   Nra  r2   r2   r2   r3   ry    rb  ry  c                   @  s&   e Zd ZU edfedffZded< dS )fieldr   r   r   N)r[   r   r   rx  ry  r   r   r2   r2   r2   r3   rz       
 rz  c                   @  r  )
field_listzList of label & data pairs.

    Typically rendered as a two-column list.
    Also used for extension syntax or special processing.
    r   r   r   N)r[   r   r   r   rz  r   r   r2   r2   r2   r3   r|    rw  r|  c                   @  r  )option_stringz4A literal command-line option. Typically monospaced.Nr  r2   r2   r2   r3   r}    r  r}  c                   @  .   e Zd ZU dZejd Zded< d
ddZd	S )option_argumentz&Placeholder text for option arguments.)	delimiterr   r   r-   r)   c                 C  s   |  ddt|  S )Nr  r   )r  r  rO   r0   r2   r2   r3   rO     s   zoption_argument.astextNr   r[   r   r   r   r   r   r   rO   r2   r2   r2   r3   r    s   
 r  c                   @  s6   e Zd ZU dZdZded< edfedffZded< dS )	optionzzOption element in an `option_list_item`.

    Groups an option string with zero or more option argument placeholders.
    r   r   r   r   r   r   N)	r[   r   r   r   r   r   r}  r  r   r2   r2   r2   r3   r    s   
 r  c                   @  s0   e Zd ZU dZdZded< edffZded< dS )option_groupz<Groups together one or more `option` elements, all synonyms.z, r   r   r   r   N)r[   r   r   r   r   r   r  r   r2   r2   r2   r3   r    s   
 r  c                   @  r  )descriptionz%Describtion of a command-line option.r   r   r   Nr  r2   r2   r2   r3   r    r  r  c                   @  s6   e Zd ZU dZdZded< edfedffZded< dS )option_list_itemzGContainer for a pair of `option_group` and `description` elements.
    z  r   r   r   r   N)	r[   r   r   r   r   r   r  r  r   r2   r2   r2   r3   r    s   
 r  c                   @  r  )option_listz9Two-column list of command-line options and descriptions.r   r   r   N)r[   r   r   r   r  r   r   r2   r2   r2   r3   r    r  r  c                   @  r  )literal_blockNr  r2   r2   r2   r3   r  	  r  r  c                   @  r  )doctest_blockNr  r2   r2   r2   r3   r  	  r  r  c                   @  r  )
math_blockz(Mathematical notation (display formula).Nr  r2   r2   r2   r3   r  		  r  r  c                   @  s   e Zd ZU dZdZded< dS )r(   z&Single line of text in a `line_block`.Nr   rE   )r[   r   r   r   rE   r   r2   r2   r2   r3   r(   	  s   
 r(   c                   @  r  )
line_blockz.Sequence of lines and nested line blocks.
    Nr  r2   r2   r2   r3   r  	  r  r  r   c                   @  r  )	attentionNr  r2   r2   r2   r3   r  	  r  r  c                   @  r  )cautionNr  r2   r2   r2   r3   r   	  r  r  c                   @  r  )dangerNr  r2   r2   r2   r3   r  !	  r  r  c                   @  r  )r  Nr  r2   r2   r2   r3   r  "	  r  r  c                   @  r  )	importantNr  r2   r2   r2   r3   r  #	  r  r  c                   @  r  )noteNr  r2   r2   r2   r3   r  $	  r  r  c                   @  r  )tipNr  r2   r2   r2   r3   r  %	  r  r  c                   @  r  )hintNr  r2   r2   r2   r3   r  &	  r  r  c                   @  r  )warningNr  r2   r2   r2   r3   r  '	  r  r  c                   @  &   e Zd ZU edfedffZded< dS )
admonitionr   r   r   r   N)r[   r   r   r  r  r   r   r2   r2   r2   r3   r  *	  r{  r  c                   @  r  )labelz/Visible identifier for footnotes and citations.Nr  r2   r2   r2   r3   r  2	  r  r  c                   @  <   e Zd ZU dZejd Zded< edfedffZ	ded< dS )	r(  zALabelled note providing additional context (footnote or endnote).)r  r   r   r   r   r   r   N)
r[   r   r   r   r   r   r   r  r  r   r2   r2   r2   r3   r(  6	  s   
 r(  c                   @  r  )r4  r   r   r   r   N)r[   r   r   r  r  r   r   r2   r2   r2   r3   r4  >	  r{  r4  c                   @  r~  )imagezPReference to an image resource.

    May be body element or inline element.
    )urialtalignheightwidthscaleloadingr   r   r-   r)   c                 C  s   |  ddS )Nr  r   r?  r0   r2   r2   r3   rO   N	  r   zimage.astextNr   r  r2   r2   r2   r3   r  F	  s   
 r  c                   @  r  )captionNr  r2   r2   r2   r3   r  R	  r  r  c                   @  r  )legendzCA wrapper for text accompanying a `figure` that is not the caption.r   r   r   Nr  r2   r2   r2   r3   r  U	  r  r  c                   @  sF   e Zd ZU dZejd Zded< eefdfe	dfe
dffZded< dS )	figurez9A formal figure, generally an illustration, with a title.)r  r  r   r   r   r   r   N)r[   r   r   r   r   r   r   r  rg  r  r  r   r2   r2   r2   r3   r  Z	  s   
 
r  c                   @  6   e Zd ZU dZejd Zded< edffZded< dS )entryz#An entry in a `row` (a table cell).)r  charcharoffcolnamecolsepmorecolsmorerowsnamestnameendrowsepvalignr   r   r   r   N)	r[   r   r   r   r   r   r   r  r   r2   r2   r2   r3   r  j	  s   
 r  c                   @  r  )rowzRow of table cells.)r  r  r   r   r   r   N)	r[   r   r   r   r   r   r   r  r   r2   r2   r2   r3   r  s	     
 r  c                   @  r~  )colspecz*Specifications for a column in a `tgroup`.)	r  r  r  r  colnumr  colwidthr  stubr   r   r-   int | floatc                 C  s   t | ddS )zReturn numerical value of "colwidth__" attribute. Default 1.

        Raise ValueError if "colwidth" is zero, negative, or a *fixed value*.

        Provisional.

        __ https://docutils.sourceforge.io/docs/ref/doctree.html#colwidth
        r  r   )validate_colwidthr  r0   r2   r2   r3   	propwidth	  s   zcolspec.propwidthN)r-   r  )r[   r   r   r   r   r   r   r  r2   r2   r2   r3   r  y	  s   
 r  c                   @  r  )theadz(Row(s) that form the head of a `tgroup`.r  r   r   r   r   N	r[   r   r   r   r   r   r   r  r   r2   r2   r2   r3   r  	  r  r  c                   @  r  )tbodyzBody of a `tgroup`.r  r   r   r   r   Nr  r2   r2   r2   r3   r  	  r  r  c                   @  sB   e Zd ZU dZejd Zded< edfedfe	dffZ
ded< d	S )
tgroupz9A portion of a table. Most tables have just one `tgroup`.)r  colsr  r  r   r   r   r   r   r   N)r[   r   r   r   r   r   r   r  r  r  r   r2   r2   r2   r3   r  	  s   
 "r  c                   @  r  )	tablez)A data arrangement with rows and columns.)r  r  framepgwider  r  r   r   r   r   r   N)
r[   r   r   r   r   r   r   r  r  r   r2   r2   r2   r3   r  	  s   
 r  c                   @  r  )commentz%Author notes, hidden from the output.Nr  r2   r2   r2   r3   r  	  r  r  c                   @  rf  )r9  )ltrimrtrimr   r   Nri  r2   r2   r2   r3   r9  	  rb  r9  c                   @  rf  )r  )rh  r  r  r  r   r   Nri  r2   r2   r2   r3   r  	  rb  r  c                   @  sN   e Zd ZU dZejd Zded< edffZded< 	ddddZ	dddZ
dS )r  z
    System message element.

    Do not instantiate this class directly; use
    ``document.reporter.info/warning/error/severe()`` instead.
    )rF   r(   rh   r   r   r   r   NrH  r   r   r   r-   r5   c                 O  s\   | dd}|rtd|}|f| }ztj| |g|R i | W d S    td|f   )Nr   r   zsystem_message: children=%r)r,  r]  r   r   print)r1   rH  r$   r   r   pr2   r2   r3   r   	  s   

 zsystem_message.__init__r)   c                 C  s0   |  dd}d| d || d | d t| f S )Nr(   r   z%s:%s: (%s/%s) %sr&   rh   rF   )r  r   rO   )r1   r(   r2   r2   r3   rO   	  s   zsystem_message.astextr7   )rH  r   r   r   r-   r5   r   )r[   r   r   r   r  r   r   r  r   r   rO   r2   r2   r2   r3   r  	  s   
 r  c                   @  s6   e Zd ZdZ		ddddZddddZdddZdS )rC  ao  
    Placeholder for pending operations.

    The "pending" element is used to encapsulate a pending operation: the
    operation (transform), the point at which to apply it, and any data it
    requires.  Only the pending operation's location within the document is
    stored in the public document tree (by the "pending" object itself); the
    operation and its data are stored in the "pending" object's internal
    instance attributes.

    For example, say you want a table of contents in your reStructuredText
    document.  The easiest way to specify where to put it is from within the
    document, with a directive::

        .. contents::

    But the "contents" directive can't do its work until the entire document
    has been parsed and possibly transformed to some extent.  So the directive
    code leaves a placeholder behind that will trigger the second phase of its
    processing, something like this::

        <pending ...public attributes...> + internal attributes

    Use `document.note_pending()` so that the
    `docutils.transforms.Transformer` stage of processing can run all pending
    transforms.
    Nr   	transformr   detailsMapping[str, Any] | Noner   r)   r   r   r-   r5   c                 O  s0   t j| |g|R i | || _	 |pi | _d S r7   )r   r   r  r  )r1   r  r  r   r$   r   r2   r2   r3   r   	  s
   
zpending.__init__rD   r   rE   rF   rG   c                   s  dd| j j| j jf dg}t| j }|D ]V\}}t|tr7|dd|f  |	dd |
  D  q|rbt|trbt|d trb|dd|f  |D ]}|	d	d |
  D  qPq|d
d||f  qt
|  d fdd|D  S )Nz.. internal attributes:z     .transform: %s.%sz     .details:z%7s%s:r   c                 S     g | ]}d d|f qS z%9s%sr   r2   r   r2   r2   r3   r   
      z#pending.pformat.<locals>.<listcomp>r   c                 S  r  r  r2   r   r2   r2   r3   r   
  r  z	%7s%s: %rc                 3  s     | ]}d   |f V  qdS )z	    %s%s
Nr2   r   r   r2   r3   r   
  s    z"pending.pformat.<locals>.<genexpr>)r  r   r[   r  r  r   ri   r!   r   r   rK   r   rz   r   r   )r1   rE   rF   	internalsr  r   r4   r   r2   r   r3   rK   
  s<   






zpending.pformatr   c                 C  s:   | j | j| j| jfi | j}| j|_| j|_| j|_|S r7   )rZ   r  r  r   r   r,   r&   r(   rf  r2   r2   r3   rL   
  s   zpending.copyrQ  )
r  r   r  r  r   r)   r   r   r-   r5   r   r   r   )r[   r   r   r   r   rK   rL   r2   r2   r2   r3   rC  	  s    rC  c                   @  r  )rawzoRaw data that is to be passed untouched to the Writer.

    Can be used as Body element or Inline element.
    )formatr  r   r   Nr  r2   r2   r2   r3   r  (
  s   
 r  c                   @  r  )abbreviationNr  r2   r2   r2   r3   r  5
  r  r  c                   @  r  )acronymNr  r2   r2   r2   r3   r  6
  r  r  c                   @  r  )emphasisNr  r2   r2   r2   r3   r  7
  r  r  c                   @  r  )	generatedNr  r2   r2   r2   r3   r  8
  r  r  c                   @  r  )inlineNr  r2   r2   r2   r3   r  9
  r  r  c                   @  r  )literalNr  r2   r2   r2   r3   r  :
  r  r  c                   @  r  )strongNr  r2   r2   r2   r3   r  ;
  r  r  c                   @  r  )	subscriptNr  r2   r2   r2   r3   r  <
  r  r  c                   @  r  )superscriptNr  r2   r2   r2   r3   r  =
  r  r  c                   @  r  )title_referenceNr  r2   r2   r2   r3   r  >
  r  r  c                   @  rf  )r+  )r  r  r  r   r   Nri  r2   r2   r2   r3   r+  A
  rb  r+  c                   @  rf  )r6  )r  r  r   r   Nri  r2   r2   r2   r3   r6  F
  rb  r6  c                   @  rf  )r@  )r  r   r   Nri  r2   r2   r2   r3   r@  J
  rb  r@  c                   @  r  )mathz&Mathematical notation in running text.Nr  r2   r2   r2   r3   r  N
  r  r  c                   @  rf  )problematic)r  r  r  r   r   Nri  r2   r2   r2   r3   r  R
  rb  r  aA  
    Text
    abbreviation acronym address admonition attention attribution author
        authors
    block_quote bullet_list
    caption caution citation citation_reference classifier colspec comment
        compound contact container copyright
    danger date decoration definition definition_list definition_list_item
        description docinfo doctest_block document
    emphasis entry enumerated_list error
    field field_body field_list field_name figure footer
        footnote footnote_reference
    generated
    header hint
    image important inline
    label legend line line_block list_item literal literal_block
    math math_block meta
    note
    option option_argument option_group option_list option_list_item
        option_string organization
    paragraph pending problematic
    raw reference revision row rubric
    section sidebar status strong subscript substitution_definition
        substitution_reference subtitle superscript system_message
    table target tbody term tgroup thead tip title title_reference topic
        transition
    version
    warningzSequence[str]node_class_namesc                   @  sR   e Zd ZU dZdZded< 	 ddd	Zdd
dZdddZdddZ	dddZ
dS )rV   a  
    "Visitor" pattern [GoF95]_ abstract superclass implementation for
    document tree traversals.

    Each node class has corresponding methods, doing nothing by
    default; override individual methods for specific and useful
    behaviour.  The `dispatch_visit()` method is called by
    `Node.walk()` upon entering a node.  `Node.walkabout()` also calls
    the `dispatch_departure()` method before exiting a node.

    The dispatch methods call "``visit_`` + node class name" or
    "``depart_`` + node class name", resp.

    This is a base class for visitors whose ``visit_...`` & ``depart_...``
    methods must be implemented for *all* compulsory node types encountered
    (such as for `docutils.writers.Writer` subclasses).
    Unimplemented methods will raise exceptions (except for optional nodes).

    For sparse traversals, where only certain node types are of interest, use
    subclass `SparseNodeVisitor` instead.  When (mostly or entirely) uniform
    processing is desired, subclass `GenericNodeVisitor`.

    .. [GoF95] Gamma, Helm, Johnson, Vlissides. *Design Patterns: Elements of
       Reusable Object-Oriented Software*. Addison-Wesley, Reading, MA, USA,
       1995.
    )r  zClassVar[tuple[str, ...]]optionalr.   r-   r5   c                C  r6   r7   )r.   r1   r.   r2   r2   r3   r   
  rt   zNodeVisitor.__init__c                 C  :   |j j}t| d| | j}| jjd|j|f  ||S )z
        Call self."``visit_`` + node class name" with `node` as
        parameter.  If the ``visit_...`` method does not exist, call
        self.unknown_visit.
        visit_z;docutils.nodes.NodeVisitor.dispatch_visit calling %s for %s)rZ   r[   rl  unknown_visitr.   rX   rY   r1   rr   	node_namemethodr2   r2   r3   r\   
     zNodeVisitor.dispatch_visitc                 C  r  )z
        Call self."``depart_`` + node class name" with `node` as
        parameter.  If the ``depart_...`` method does not exist, call
        self.unknown_departure.
        depart_z?docutils.nodes.NodeVisitor.dispatch_departure calling %s for %s)rZ   r[   rl  unknown_departurer.   rX   rY   r  r2   r2   r3   re   
  r  zNodeVisitor.dispatch_departurec                 C  2   | j jjs|jj| jvrtd| j|jjf dS )zk
        Called when entering unknown `Node` types.

        Raise an exception unless overridden.
        z!%s visiting unknown node type: %sNr.   r   strict_visitorrZ   r[   r  rJ   r   r2   r2   r3   r  
     
zNodeVisitor.unknown_visitc                 C  r  )zi
        Called before exiting unknown `Node` types.

        Raise exception unless overridden.
        z"%s departing unknown node type: %sNr  r   r2   r2   r3   r  
  r  zNodeVisitor.unknown_departureNr.   r.   r-   r5   r   )r[   r   r   r   r  r   r   r\   re   r  r  r2   r2   r2   r3   rV   z
  s   
 
	


rV   c                   @  r  )SparseNodeVisitora  
    Base class for sparse traversals, where only certain node types are of
    interest.  When ``visit_...`` & ``depart_...`` methods should be
    implemented for *all* node types (such as for `docutils.writers.Writer`
    subclasses), subclass `NodeVisitor` instead.
    Nr  r2   r2   r2   r3   r  
  r  r  c                   @  s    e Zd ZdZdd Zdd ZdS )GenericNodeVisitora  
    Generic "Visitor" abstract superclass, for simple traversals.

    Unless overridden, each ``visit_...`` method calls `default_visit()`, and
    each ``depart_...`` method (when using `Node.walkabout()`) calls
    `default_departure()`. `default_visit()` (and `default_departure()`) must
    be overridden in subclasses.

    Define fully generic visitors by overriding `default_visit()` (and
    `default_departure()`) only. Define semi-generic visitors by overriding
    individual ``visit_...()`` (and ``depart_...()``) methods also.

    `NodeVisitor.unknown_visit()` (`NodeVisitor.unknown_departure()`) should
    be overridden for default behavior.
    c                 C  rH   z)Override for generic, uniform traversals.rI   r   r2   r2   r3   default_visit
  rM   z GenericNodeVisitor.default_visitc                 C  rH   r  rI   r   r2   r2   r3   default_departure
  rM   z$GenericNodeVisitor.default_departureN)r[   r   r   r   r  r  r2   r2   r2   r3   r  
  s    r  r1   r-   r5   c                 C  r&  r7   )r  r   r2   r2   r3   _call_default_visit
  r   r  c                 C  r&  r7   )r  r   r2   r2   r3   _call_default_departure
  r   r  c                 C  s   d S r7   r2   r   r2   r2   r3   _nop  s   r  c                 C  sN   | D ]"}t td| t t td| t t td| t t td| t qdS )z%Save typing with dynamic assignments:r  r  N)setattrr  r  r  r  r  )r   _namer2   r2   r3   _add_node_class_names  s   r  c                      s>   e Zd ZdZd fddZdd Zdd	d
ZdddZ  ZS )TreeCopyVisitorzQ
    Make a complete copy of a tree or branch, including element attributes.
    r.   r-   r5   c                   s   t  | g | _g | _d S r7   )r  r   parent_stackr#   r  r  r2   r3   r     s   
zTreeCopyVisitor.__init__c                 C  s
   | j d S r  )r#   r0   r2   r2   r3   get_tree_copy  rt   zTreeCopyVisitor.get_tree_copyc                 C  s,   |  }| j| | j| j || _dS )z9Copy the current node, and make it the new acting parent.N)rL   r#   r   r  )r1   rr   newnoder2   r2   r3   r    s   
zTreeCopyVisitor.default_visitc                 C  s   | j  | _dS )z#Restore the previous acting parent.N)r  r,  r#   r   r2   r2   r3   r  %  s   z!TreeCopyVisitor.default_departurer  r   )	r[   r   r   r   r   r  r  r  r  r2   r2   r  r3   r    s    
r  c                      s$   e Zd ZdZdd fd	d
Z  ZS )r{  z'Invalid Docutils Document Tree Element.Nr  r)   rw  r   r-   r5   c                   s   t  | || _d S r7   )r  r   rw  )r1   r  rw  r  r2   r3   r   /  s   
zValidationError.__init__r7   )r  r)   rw  r   r-   r5   )r[   r   r   r   r   r  r2   r2   r  r3   r{  -  s    r{  c                   @  r  )TreePruningExceptionz
    Base class for `NodeVisitor`-related tree pruning exceptions.

    Raise subclasses from within ``visit_...`` or ``depart_...`` methods
    called from `Node.walk()` and `Node.walkabout()` tree traversals to prune
    the tree traversed.
    Nr  r2   r2   r2   r3   r  4  r  r  c                   @  r  )r]   z
    Do not visit any children of the current node.  The current node's
    siblings and ``depart_...`` method are not affected.
    Nr  r2   r2   r2   r3   r]   >  r  r]   c                   @  r  )ra   z
    Do not visit any more siblings (to the right) of the current node.  The
    current node's children and its ``depart_...`` method are not affected.
    Nr  r2   r2   r2   r3   ra   E  r  ra   c                   @  r  )r^   zq
    Do not visit the current node's children, and do not call the current
    node's ``depart_...`` method.
    Nr  r2   r2   r2   r3   r^   L  r  r^   c                   @  r  )r_   z
    Do not call the current node's ``depart_...`` method.  The current node's
    children and siblings are not affected.
    Nr  r2   r2   r2   r3   r_   S  r  r_   c                   @  r  )	NodeFoundz
    Raise to indicate that the target of a search has been found.  This
    exception must be caught by the client; it is not caught by the traversal
    code.
    Nr  r2   r2   r2   r3   r  Z  r  r  c                   @  r  )rb   a<  
    Stop the traversal altogether.  The current node's ``depart_...`` method
    is not affected.  The parent nodes ``depart_...`` methods are also called
    as usual.  No other nodes are visited.  This is an alternative to
    NodeFound that does not cause exception handling to trickle up to the
    caller.
    Nr  r2   r2   r2   r3   rb   b  r  rb   r  r)   restore_backslashesrW   respect_whitespacec                 C  s.   |r|  ddS dD ]
}d| |} q
| S )zw
    Return a string with nulls removed or restored to backslashes.
    Backslash-escaped spaces are also removed.
     \)  z 
r  r   )rA  r   split)r  r  r  sepr2   r2   r3   r   m  s
   	r   stringc                 C  s`   |   }|t}|t}td|ddd}t	dd
| }t	d|}t|S )a  
    Convert `string` into an identifier and return it.

    Docutils identifiers will conform to the regular expression
    ``[a-z](-?[a-z0-9]+)*``.  For CSS compatibility, identifiers (the "class"
    and "id" attributes) should have no underscores, colons, or periods.
    Hyphens may be used.

    - The `HTML 4.01 spec`_ defines identifiers based on SGML tokens:

          ID and NAME tokens must begin with a letter ([A-Za-z]) and may be
          followed by any number of letters, digits ([0-9]), hyphens ("-"),
          underscores ("_"), colons (":"), and periods (".").

    - However the `CSS1 spec`_ defines identifiers based on the "name" token,
      a tighter interpretation ("flex" tokenizer notation; "latin1" and
      "escape" 8-bit characters have been replaced with entities)::

          unicode     \[0-9a-f]{1,4}
          latin1      [&iexcl;-&yuml;]
          escape      {unicode}|\[ -~&iexcl;-&yuml;]
          nmchar      [-a-z0-9]|{latin1}|{escape}
          name        {nmchar}+

    The CSS1 "nmchar" rule does not include underscores ("_"), colons (":"),
    or periods ("."), therefore "class" and "id" attributes should not contain
    these characters. They should be replaced with hyphens ("-"). Combined
    with HTML's requirements (the first character must be a letter; no
    "unicode", "latin1", or "escape" characters), this results in the
    ``[a-z](-?[a-z0-9]+)*`` pattern.

    .. _HTML 4.01 spec: https://www.w3.org/TR/html401
    .. _CSS1 spec: https://www.w3.org/TR/REC-CSS1
    NFKDasciiignorer  r   r   )r   	translate_non_id_translate_digraphs_non_id_translateunicodedata	normalizeencodedecode_non_id_charssubr   r  _non_id_at_endsr)   )r  rh  r2   r2   r3   r  ~  s   #

r  z
[^a-z0-9]+zre.Pattern[str]r  z^[-0-9]+|-+$r     oi  di'  hi1  r+  iB  lig  ti  bi  i  r   i  i  fi  ki  i  r   i  r  i  i  i  yi  zi  gi%  i4  i5  i6  i7  ji<  i?  r  i@  iG  r~  iI  iK  qiM  riO  zdict[int, str]r	  szaeoedbqp)      iS  i8  i9  r  rr   r   c                 C  s&   | d  | | d | d| _d S )Nr   r   T)r   r/  rk  )rr   r   r2   r2   r3   r    s   
r  c                 C  s   d |   S )z.Return a case- and whitespace-normalized name.r   )r   r   r  r   r2   r2   r3   r<    rG  r<  c                 C  s   d |  S )z$Return a whitespace-normalized name.r   )r   r  r'  r2   r2   r3   r;    s   r;  r4   c                 C  s   |  dd ddS )zDEscape string values that are elements of a list, for serialization.r  z\\r   z\ rA  r4   r2   r2   r3   r     s   r   	list[str]c                 C  s<   |  dd} |  dd} |  dd} | d}dd |D S )a  Split a string at non-escaped whitespace.

    Backslashes escape internal whitespace (cf. `serial_escape()`).
    Return list of "names" (after removing escaping backslashes).

    >>> split_name_list(r'a\ n\ame two\\ n\\ames'),
    ['a name', 'two\\', r'n\ames']

    Provisional.
    r  r    r   r   c                 S  s    g | ]}| d d ddqS )r+  r   r  r   r(  r   r   r2   r2   r3   r     s    z#split_name_list.<locals>.<listcomp>)rA  r  )r  r   r2   r2   r3   split_name_list  s   
r-  c                 C  s   d|  S )zQuote attributes for pseudo-xmlz"%s"r2   r)  r2   r2   r3   r     s   r      [a-zA-Zµ]*|%?measureunit_patterntuple[int | float, str]c              	   C  s   t d| d| }z$z	t|d}W n ty$   t|d}Y nw |d}W ||fS  ttfy?   td|  dw )ar  Parse a measure__, return value + unit.

    `unit_pattern` is a regular expression describing recognized units.
    The default is suited for (but not limited to) CSS3 units and SI units.
    It matches runs of ASCII letters or Greek mu, a single percent sign,
    or no unit.

    __ https://docutils.sourceforge.io/docs/ref/doctree.html#measure

    Provisional.
    z(-?[0-9.]+) *()ru   r{   "z" is no valid measure.)re	fullmatchrG   groupry  floatr/   )r/  r0  matchr4   unitr2   r2   r3   parse_measure  s   r:  keywordsCallable[[str], str]c                    s   d fdd}|S )z^
    Return a function that validates a `str` against given `keywords`.

    Provisional.
    r4   r)   r-   c                   s,   |  vrd  }td|  d| d| S )Nrr  r3  z" is not one of "rs  )r   ry  )r4   allowedr;  r2   r3   validate_keywords9  s   
z3create_keyword_validator.<locals>.validate_keywordsNr4   r)   r-   r)   r2   )r;  r?  r2   r>  r3   create_keyword_validator3  s   rA  c                 C  s    | t | krtd|  d| S )z
    Validate identifier key or class name.

    Used in `idref.type`__ and for the tokens in `validate_identifier_list()`.

    __ https://docutils.sourceforge.io/docs/ref/doctree.html#idref-type

    Provisional.
    r3  z" is no valid id or class name.)r  ry  r)  r2   r2   r3   validate_identifierA  s   
rB  str | list[str]c                 C  (   t | tr	|  } | D ]}t| q| S )a  
    A (space-separated) list of ids or class names.

    `value` may be a `list` or a `str` with space separated
    ids or class names (cf. `validate_identifier()`).

    Used in `classnames.type`__, `ids.type`__, and `idrefs.type`__.

    __ https://docutils.sourceforge.io/docs/ref/doctree.html#classnames-type
    __ https://docutils.sourceforge.io/docs/ref/doctree.html#ids-type
    __ https://docutils.sourceforge.io/docs/ref/doctree.html#idrefs-type

    Provisional.
    )ri   r)   r  rB  r4   tokenr2   r2   r3   validate_identifier_listP  s
   

rG  c                 C  s   t | \}}| | S )ut  
    Validate a measure__ (number + optional unit).  Return normalized `str`.

    See `parse_measure()` for a function returning a "number + unit" tuple.

    The unit may be a run of ASCII letters or Greek mu, a single percent sign,
    or the empty string. Case is preserved.

    Provisional.

    __ https://docutils.sourceforge.io/docs/ref/doctree.html#measure
    )r:  )r/  r4   r9  r2   r2   r3   validate_measuref  s   rH  str | int | floatr  c                 C  sj   t | ttfr
| }n| dv rd}nz
t| dd\}}W n ty&   d}Y nw |dkr3td|  d|S )	uO  Validate the "colwidth__" attribute.

    Provisional:
        `measure` must be a `str` and will be returned as normalized `str`
        (with unit "*" for proportional values) in Docutils 1.0.

        The default unit will change to "pt" in Docutils 2.0.

    __ https://docutils.sourceforge.io/docs/ref/doctree.html#colwidth
    )r   r   ru   z[*]?)r0  r*  r   r3  z" is no proportional measure.)ri   rG   r7  r:  ry  )r/  r4   _unitr2   r2   r3   r  w  s   r  c                 C  s    t d| std|  d| S )za
    Validate a "name token": a `str` of ASCII letters, digits, and [-._].

    Provisional.
    z[-._A-Za-z0-9]+r3  z" is no NMTOKEN.)r4  r5  ry  r)  r2   r2   r3   validate_NMTOKEN  s   rK  c                 C  rD  )z=
    Validate a list of "name tokens".

    Provisional.
    )ri   r)   r  rK  rE  r2   r2   r3   validate_NMTOKENS  s
   

rL  c                 C  s    t | tr	t| } dd | D S )a  
    Validate a list of `reference names`__.

    Reference names may contain all characters;
    whitespace is normalized (cf, `whitespace_normalize_name()`).

    `value` may be either a `list` of names or a `str` with
    space separated names (with internal spaces backslash escaped
    and literal backslashes doubled cf. `serial_escape()`).

    Return a list of whitespace-normalized, unescaped reference names.

    Provisional.

    __ https://docutils.sourceforge.io/docs/ref/doctree.html#reference-name
    c                 S  s   g | ]}t |qS r2   rA  r,  r2   r2   r3   r     r   z)validate_refname_list.<locals>.<listcomp>)ri   r)   r-  r)  r2   r2   r3   validate_refname_list  s   
rM  str | int | boolc                 C  s   | dkrdS t | S )zValidate a `%yesorno`__ (flag) value.

    The string literal "0" evaluates to ``False``, all other
    values are converterd with `bool()`.

    __ https://docutils.sourceforge.io/docs/ref/doctree.html#yesorno
    0F)rW   r)  r2   r2   r3   validate_yesorno  s   rP  r  r  rh  r  r   rm  r   r  r  r  r  r  r  r  r  r  r  ltrrtlr   rp  arabic
loweralpha
lowerroman
upperalpha
upperromanr  r  topbottomtopbotallsidesnoner  r  r   r  rF   r  r  embedlinklazyr  r  r  r   r  r  r  r  r  r  r  r  r  r  r  r&   r   r  rq  rh   middledefaultr  )r  r  r  r  zdict[str, Callable[[str], Any]]rx  )r1   r  r-   r5   )r1   r  r-   r5   r   )FF)r  r)   r  rW   r  rW   r-   r)   )r  r)   r-   r)   )rr   r   r   r)   r-   r5   )r   r)   r-   r)   r@  )r  r)   r-   r*  )r.  )r/  r)   r0  r)   r-   r1  )r;  r)   r-   r<  )r4   rC  r-   r*  )r/  r)   r-   r)   )r/  rI  r-   r  )r4   rN  r-   rW   )r   
__future__r   __docformat__rM  r4  r  r
  r~   collectionsr   TYPE_CHECKINGcollections.abcr   r   r   r   r	   typesr
   typingr   r   r   r   r   r   docutils.utils._typingr   xml.domr   docutils.frontendr   r  r   r   docutils.utilsr   r^  r   r   _ContentModelQuantifierr   r   r)   PathLiker   rW   r    r!   r   r   r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r2  r   r.   rR  rS  rT  rU  rV  rW  rX  rY  rZ  r[  r]  r^  r`  rc  rd  re  rg  rj  rl  ro  rr  rs  rt  ru  rv  rx  ry  rz  r|  r}  r  r  r  r  r  r  r  r  r  r(   r  r  r  r  r  r  r  r  r  r  r  r  r(  r4  r  r  r  r  r  r  r  r  r  r  r  r  r9  r  r  rC  r  r  r  r  r  r  r  r  r  r  r  r+  r6  r@  r  r  r  r  rV   r  r  r  r  r  r  r  ry  r{  	Exceptionr  r]   ra   r^   r_   r  rb   r   r  compiler  r  r	  r  r  r<  r;  r   r-  r   r:  rA  rB  rG  rH  r  rK  rL  rM  rP  rG   rx  r2   r2   r2   r3   <module>   s"     NI       

!"

   4 

	
	 N	\		
0	
 !$	'	
 !"#%&'()*+,-./01234567<