U
    [ªShÓ  ã                   @   sÚ   d Z dZddlmZmZ ddlmZ G dd„ deƒZG dd„ deƒZG d	d
„ d
eƒZ	G dd„ deƒZ
G dd„ deƒZG dd„ deƒZG dd„ deƒZG dd„ deƒZG dd„ deƒZG dd„ deƒZG dd„ dejƒZdS )z&
Transforms for resolving references.
ÚreStructuredTexté    )ÚnodesÚutils)Ú	Transformc                   @   s   e Zd ZdZdZdd„ ZdS )ÚPropagateTargetsa}  
    Propagate empty internal targets to the next element.

    Given the following nodes::

        <target ids="internal1" names="internal1">
        <target anonymous="1" ids="id1">
        <target ids="internal2" names="internal2">
        <paragraph>
            This is a test.

    PropagateTargets propagates the ids and names of the internal
    targets preceding the paragraph to the paragraph itself::

        <target refid="internal1">
        <target anonymous="1" refid="id1">
        <target refid="internal2">
        <paragraph ids="internal2 id1 internal1" names="internal2 internal1">
            This is a test.
    i  c                 C   s‚  | j  tj¡D ]l}t|jtjƒs| d¡s| d¡s| d¡rBqt|ƒdksVt	dƒ‚|j
dd}t|tjƒr~|j
ddd	}qb|d kst|tjtjfƒr¦t|tjƒs¦q|d
  |d
 ¡ |d  |d ¡ t|dƒsÚi |_t|dƒsêi |_|d
 D ]}|| j j|< ||j|< qò|d D ]}||j|< q|j t|di ƒ¡ |j t|di ƒ¡ |d
 d |d< g |d
< g |d< | j  |¡ qd S )NÚrefidÚrefuriÚrefnamer   z&error: block-level target has childrenT)ÚascendF)r
   ZdescendÚidsÚnamesÚexpect_referenced_by_nameÚexpect_referenced_by_id)ÚdocumentÚfindallr   ÚtargetÚ
isinstanceÚparentZTextElementÚhasattrÚlenÚAssertionErrorÚ	next_nodeZsystem_messageZ	InvisibleZ
TargetableÚextendr   r   r   ÚupdateÚgetattrÚ
note_refid)Úselfr   r   ÚidÚname© r   úQ/root/rtd-docs/venv/lib/python3.8/site-packages/docutils/transforms/references.pyÚapply(   sP    ÿÿþÿ
þ


ÿ
ÿzPropagateTargets.applyN©Ú__name__Ú
__module__Ú__qualname__Ú__doc__Údefault_priorityr!   r   r   r   r    r      s   r   c                   @   s   e Zd ZdZdZdd„ ZdS )ÚAnonymousHyperlinksa¥  
    Link anonymous references to targets.  Given::

        <paragraph>
            <reference anonymous="1">
                internal
            <reference anonymous="1">
                external
        <target anonymous="1" ids="id1">
        <target anonymous="1" ids="id2" refuri="http://external">

    Corresponding references are linked via "refid" or resolved via "refuri"::

        <paragraph>
            <reference anonymous="1" refid="id1">
                text
            <reference anonymous="1" refuri="http://external">
                external
        <target anonymous="1" ids="id1">
        <target anonymous="1" ids="id2" refuri="http://external">
    i¸  c           
      C   sP  g }g }| j  tj¡D ]}| d¡r| |¡ q| j  tj¡D ]}| d¡r>| |¡ q>t|ƒt|ƒkrÔ| j j 	dt|ƒt|ƒf ¡}| j  
|¡}|D ]8}tj|j|j|d}| j  
|¡}| |¡ | |¡ q–d S t||ƒD ]l\}}	d|	_|	 d¡r|	d |d< d|_qÞqì|	d s*| j j|	d  }	qì|	d d |d< | j  |¡ qÞqìqÞd S )	NÚ	anonymousz]Anonymous hyperlink mismatch: %s references but %s targets.
See "backrefs" attribute for IDs.©r   é   r   r   r   r   )r   r   r   Ú	referenceÚgetÚappendr   r   ÚreporterÚerrorÚset_idÚproblematicÚ	rawsourceÚadd_backrefÚreplace_selfÚzipÚ
referencedr   Úresolvedr   r   )
r   Zanonymous_refsZanonymous_targetsÚnodeÚmsgÚmsgidÚrefÚprbÚprbidr   r   r   r    r!   s   sJ    

þÿ  ÿ

zAnonymousHyperlinks.applyNr"   r   r   r   r    r(   Y   s   r(   c                   @   sD   e Zd ZdZdZdd„ Zdd„ Zdd„ Zd	d
„ Zdd„ Z	dd„ Z
dS )ÚIndirectHyperlinksaN  
    a) Indirect external references::

           <paragraph>
               <reference refname="indirect external">
                   indirect external
           <target id="id1" name="direct external"
               refuri="http://indirect">
           <target id="id2" name="indirect external"
               refname="direct external">

       The "refuri" attribute is migrated back to all indirect targets
       from the final direct target (i.e. a target not referring to
       another indirect target)::

           <paragraph>
               <reference refname="indirect external">
                   indirect external
           <target id="id1" name="direct external"
               refuri="http://indirect">
           <target id="id2" name="indirect external"
               refuri="http://indirect">

       Once the attribute is migrated, the preexisting "refname" attribute
       is dropped.

    b) Indirect internal references::

           <target id="id1" name="final target">
           <paragraph>
               <reference refname="indirect internal">
                   indirect internal
           <target id="id2" name="indirect internal 2"
               refname="final target">
           <target id="id3" name="indirect internal"
               refname="indirect internal 2">

       Targets which indirectly refer to an internal target become one-hop
       indirect (their "refid" attributes are directly set to the internal
       target's "id"). References which indirectly refer to an internal
       target become direct internal references::

           <target id="id1" name="final target">
           <paragraph>
               <reference refid="id1">
                   indirect internal
           <target id="id2" name="indirect internal 2" refid="id1">
           <target id="id3" name="indirect internal" refid="id1">
    iÌ  c                 C   s,   | j jD ]}|js|  |¡ |  |¡ qd S ©N)r   Zindirect_targetsr8   Úresolve_indirect_targetÚresolve_indirect_references©r   r   r   r   r    r!   Ð   s    
zIndirectHyperlinks.applyc                 C   sL  |  d¡}|d kr|d }n<| jj  |¡}|sX| jjjD ]}||ƒr8 qTq8|  |¡ d S | jj| }|j|d t|t	j
ƒr¸|js¸| d¡r¸t|dƒr¤|  |¡ d S d|_|  |¡ |`| d¡rÞ|d |d< d|krÜ|d= nT| d¡r|d |d< | j |¡ n.|d r$||d< | j |¡ n|  |¡ d S |d k	rB|d= d|_d S )Nr	   r   ©r   Úmultiply_indirectr+   r   r   )r-   r   ÚnameidsÚtransformerÚunknown_reference_resolversÚnonexistent_indirect_targetr   Únote_referenced_byr   r   r   r8   r   Úcircular_indirect_referencerE   rA   r   )r   r   r	   Zreftarget_idÚresolver_functionZ	reftargetr   r   r    rA   Ö   sN    

ÿ
ÿþ






z*IndirectHyperlinks.resolve_indirect_targetc                 C   s.   |d | j jkr|  |d¡ n|  |d¡ d S )Nr	   z>which is a duplicate, and cannot be used as a unique referencezwhich does not exist)r   rF   Úindirect_target_errorrC   r   r   r    rI     s    z.IndirectHyperlinks.nonexistent_indirect_targetc                 C   s   |   |d¡ d S )Nzforming a circular reference)rM   rC   r   r   r    rK   	  s    z.IndirectHyperlinks.circular_indirect_referencec                 C   sþ   d}g }|d r d|d d  }|d D ]}|  | jj |g ¡¡ q(|d D ]}|  | jj |g ¡¡ qL|d r„|d|d d  7 }| jjjd||d |f |d	}| j |¡}t 	|¡D ]8}	t
j|	j|	j|d
}
| j |
¡}| |¡ |	 |
¡ qºd|_d S )NÚ r   z"%s" r   r   z	(id="%s")z7Indirect hyperlink target %s refers to target "%s", %s.r	   ©Ú	base_noder*   r+   )r   r   Úrefnamesr-   Úrefidsr/   r0   r1   r   Zuniqr   r2   r3   r4   r5   r8   )r   r   ZexplanationÚnamingÚreflistr   r   r:   r;   r<   r=   r>   r   r   r    rM     s6    ÿþ  ÿ
z(IndirectHyperlinks.indirect_target_errorc           	      C   s*  |  d¡rd}| jj}n|  d¡r,d}d }nd S || }|d D ]l}| jj |g ¡}|rd|j|d |D ]B}|jrtqh|d= |||< |rŽ||ƒ d|_t|tj	ƒrh|  
|¡ qhq@|d D ]n}| jj |g ¡}|rÚ|j|d |D ]D}|jrêqÞ|d= |||< |r||ƒ d|_t|tj	ƒrÞ|  
|¡ qÞq¶d S )	Nr   r   r   ©r   r	   r+   r   rD   )r   r   r   rQ   r-   rJ   r8   r   r   r   rB   rR   )	r   r   ZattnameZcall_methodZattvalr   rT   r<   r   r   r   r    rB   #  sH    


z.IndirectHyperlinks.resolve_indirect_referencesN)r#   r$   r%   r&   r'   r!   rA   rI   rK   rM   rB   r   r   r   r    r?   š   s   2,r?   c                   @   s   e Zd ZdZdZdd„ ZdS )ÚExternalTargetsa¸  
    Given::

        <paragraph>
            <reference refname="direct external">
                direct external
        <target id="id1" name="direct external" refuri="http://direct">

    The "refname" attribute is replaced by the direct "refuri" attribute::

        <paragraph>
            <reference refuri="http://direct">
                direct external
        <target id="id1" name="direct external" refuri="http://direct">
    i€  c                 C   s~   | j  tj¡D ]j}| d¡r|d }|d D ]J}| j j |g ¡}|rP|j|d |D ] }|jr`qT|d= ||d< d|_qTq,qd S )Nr   r   rU   r	   r+   )	r   r   r   r   r   rQ   r-   rJ   r8   )r   r   r   r   rT   r<   r   r   r    r!   _  s    
zExternalTargets.applyNr"   r   r   r   r    rV   K  s   rV   c                   @   s    e Zd ZdZdd„ Zdd„ ZdS )ÚInternalTargetsi”  c                 C   s6   | j  tj¡D ]"}| d¡s| d¡s|  |¡ qd S )Nr   r   )r   r   r   r   r   Úresolve_reference_idsrC   r   r   r    r!   s  s    zInternalTargets.applyc                 C   sj   |d D ]\}| j j |¡}| j j |g ¡}|r:|j|d |D ]$}|jrJq>|r\|d= ||d< d|_q>qdS )aº  
        Given::

            <paragraph>
                <reference refname="direct internal">
                    direct internal
            <target id="id1" name="direct internal">

        The "refname" attribute is replaced by "refid" linking to the target's
        "id"::

            <paragraph>
                <reference refid="id1">
                    direct internal
            <target id="id1" name="direct internal">
        r   rU   r	   r   r+   N)r   rF   r-   rQ   rJ   r8   )r   r   r   r   rT   r<   r   r   r    rX   x  s    z%InternalTargets.resolve_reference_idsN)r#   r$   r%   r'   r!   rX   r   r   r   r    rW   o  s   rW   c                
   @   s`   e Zd ZdZdZdZdddddd	d
dddg
Zdd„ Zdd„ Zdd„ Z	dd„ Z
dd„ Zdd„ ZdS )Ú	Footnotesaì  
    Assign numbers to autonumbered footnotes, and resolve links to footnotes,
    citations, and their references.

    Given the following ``document`` as input::

        <document>
            <paragraph>
                A labeled autonumbered footnote reference:
                <footnote_reference auto="1" id="id1" refname="footnote">
            <paragraph>
                An unlabeled autonumbered footnote reference:
                <footnote_reference auto="1" id="id2">
            <footnote auto="1" id="id3">
                <paragraph>
                    Unlabeled autonumbered footnote.
            <footnote auto="1" id="footnote" name="footnote">
                <paragraph>
                    Labeled autonumbered footnote.

    Auto-numbered footnotes have attribute ``auto="1"`` and no label.
    Auto-numbered footnote_references have no reference text (they're
    empty elements). When resolving the numbering, a ``label`` element
    is added to the beginning of the ``footnote``, and reference text
    to the ``footnote_reference``.

    The transformed result will be::

        <document>
            <paragraph>
                A labeled autonumbered footnote reference:
                <footnote_reference auto="1" id="id1" refid="footnote">
                    2
            <paragraph>
                An unlabeled autonumbered footnote reference:
                <footnote_reference auto="1" id="id2" refid="id3">
                    1
            <footnote auto="1" id="id3" backrefs="id2">
                <label>
                    1
                <paragraph>
                    Unlabeled autonumbered footnote.
            <footnote auto="1" id="footnote" name="footnote" backrefs="id1">
                <label>
                    2
                <paragraph>
                    Labeled autonumbered footnote.

    Note that the footnotes are not in the same order as the references.

    The labels and reference text are added to the auto-numbered ``footnote``
    and ``footnote_reference`` elements.  Footnote elements are backlinked to
    their references via "refids" attributes.  References are assigned "id"
    and "refid" attributes.

    After adding labels and reference text, the "auto" attributes can be
    ignored.
    il  NÚ*u   â€ u   â€¡õ   Â§õ   Â¶ú#u   â™ u   â™¥u   â™¦u   â™£c                 C   s:   g | _ | jj}|  |¡| j_|  |¡ |  ¡  |  ¡  d S r@   )Úautofootnote_labelsr   Zautofootnote_startÚnumber_footnotesÚnumber_footnote_referencesÚsymbolize_footnotesÚresolve_footnotes_and_citations)r   Ústartnumr   r   r    r!   ê  s    
zFootnotes.applyc                 C   s  | j jD ]
}t|ƒ}|d7 }|| j jkrq.q| dt d|¡¡ |d D ]}| j j |g ¡D ]z}|t 	|¡7 }| 
d¡ t|d ƒt|d ƒ  krždks¤n t‚|d d |d< | |d d ¡ | j  |¡ d|_q^qJ|d s|d s|d  |¡ | j  ||¡ | j |¡ q|S )	z«
        Assign numbers to autonumbered footnotes.

        For labeled autonumbered footnotes, copy the number over to
        corresponding footnote references.
        r+   r   rN   r   r	   r   r   Zdupnames)r   ZautofootnotesÚstrrF   Úinsertr   ÚlabelÚfootnote_refsr-   ÚTextÚdelattrr   r   r4   r   r8   r.   Únote_explicit_targetr^   )r   rc   Úfootnoterf   r   r<   r   r   r    r_   ò  s(    
*
zFootnotes.number_footnotesc              
   C   sJ  d}| j jD ]6}|js| d¡r$qz| j| }W n  tk
rÒ   | j jjdt| jƒ |d}| j  	|¡}| j j|d… D ]J}|jsz| d¡rqzt
j|j|j|d}| j  	|¡}| |¡ | |¡ qzY  qFY nX |t
 |¡7 }| j j| }	| j j|	 }
|	|d< | j  |¡ t|d ƒd	ks$t‚|
 |d d ¡ d	|_|d	7 }qdS )
z3Assign numbers to autonumbered footnote references.r   r   zUToo many autonumbered footnote references: only %s corresponding footnotes available.rO   Nr	   r*   r   r+   )r   Zautofootnote_refsr8   r   r^   Ú
IndexErrorr/   r0   r   r1   r   r2   r3   r4   r5   rh   rF   r   r   r   )r   rc   Úir<   rf   r:   r;   r=   r>   r   rk   r   r   r    r`     sF    þý  ÿ
z$Footnotes.number_footnote_referencesc              
   C   sž  g }| j jD ]h}t| j jt| jƒƒ\}}| j| |d  }| |¡ | dt 	d|¡¡ | j  jd7  _| j  
|¡ qd}| j jD ]}z|t || ¡7 }W n  tk
r>   | j jjdt|ƒ |d}| j  
|¡}	| j j|d… D ]J}|jsæ| d¡rüqætj|j|j|	d}
| j  
|
¡}| |¡ | |
¡ qæY  qšY nX | j j| }t|d	 ƒdksbt‚|d	 d |d< | j  |¡ | |d	 d ¡ |d7 }q‚dS )
z<Add symbols indexes to "[*]"-style footnotes and references.r+   r   rN   zOToo many symbol footnote references: only %s corresponding footnotes available.rO   Nr   r*   r   )r   Zsymbol_footnotesÚdivmodZsymbol_footnote_startr   Úsymbolsr.   re   r   rf   r1   Zsymbol_footnote_refsrh   rl   r/   r0   r8   r   r2   r3   r4   r5   r   r   )r   Úlabelsrk   ZrepsÚindexZ	labeltextrm   r<   r:   r;   r=   r>   r   r   r    ra   0  sP    ÿ
ÿý  ÿ
zFootnotes.symbolize_footnotesc                 C   s„   | j jD ]6}|d D ](}|| j jkr| j j| }|  ||¡ qq| j jD ]6}|d D ](}|| j jkrT| j j| }|  ||¡ qTqHdS )za
        Link manually-labeled footnotes and citations to/from their
        references.
        r   N)r   Z	footnotesrg   Úresolve_referencesZ	citationsZcitation_refs)r   rk   rf   rT   Zcitationr   r   r    rb   U  s    z)Footnotes.resolve_footnotes_and_citationsc                 C   sz   t |d ƒdkst‚|d d }|D ]J}|jr0q$| d¡ ||d< t |d ƒdksVt‚| |d d ¡ d|_q$d|_d S )Nr   r+   r   r	   r   )r   r   r8   ri   r4   )r   ZnoterT   r   r<   r   r   r    rr   e  s    
zFootnotes.resolve_references)r#   r$   r%   r&   r'   r^   ro   r!   r_   r`   ra   rb   rr   r   r   r   r    rY   —  s(   ;ò!%rY   c                   @   s   e Zd ZdS )Ú#CircularSubstitutionDefinitionErrorN)r#   r$   r%   r   r   r   r    rs   s  s   rs   c                   @   s   e Zd ZdZdZdd„ ZdS )ÚSubstitutionsaD  
    Given the following ``document`` as input::

        <document>
            <paragraph>
                The
                <substitution_reference refname="biohazard">
                    biohazard
                 symbol is deservedly scary-looking.
            <substitution_definition name="biohazard">
                <image alt="biohazard" uri="biohazard.png">

    The ``substitution_reference`` will simply be replaced by the
    contents of the corresponding ``substitution_definition``.

    The transformed result will be::

        <document>
            <paragraph>
                The
                <image alt="biohazard" uri="biohazard.png">
                 symbol is deservedly scary-looking.
            <substitution_definition name="biohazard">
                <image alt="biohazard" uri="biohazard.png">
    éÜ   c              
   C   s2  | j j}| j j}i }t| j jddƒ}t| j  tj¡ƒ}|D ]ð}d}|d }||krZ|}	n| 	¡ }
| 
|
d ¡}	|	d krŽ| j jjd| |d}n*||	 }t| ¡ ƒ|kr¸| j j d|	 ¡}|rþ| j  |¡}tj|j|j|d}| j  |¡}| |¡ | |¡ q:|j}| |¡}d	|jks&d
|jkr^|dkr^t||d  tjƒr^||d   ¡ ||d < d|jksvd
|jkr¶t|ƒ|d kr¶t||d  tjƒr¶||d   ¡ ||d < | ¡ }z^| tj¡D ]L}||d  	¡  }|| |g ¡kröt‚||  |	¡ ||d< | |¡ qÌW nÐ tk
rì   |j}t|tjƒrr| j jjdt  |j|j¡|j!|d}| |¡ nr|}| "d¡rŽ|d }qv| j jjd| |d}| j  |¡}tj|j|j|d}| j  |¡}| |¡ | |¡ Y q:Y nX | |j#¡ |j#D ]*}t|tj$ƒr d|kr | j  %|¡ q q:d S )NÚline_length_limiti'  rN   r	   z(Undefined substitution referenced: "%s".rO   z;Substitution definition "%s" exceeds the line-length-limit.r*   ZltrimZtrimr   r+   Zrtrimz
ref-originz*Circular substitution definition detected:)ÚlinerP   z2Circular substitution definition referenced: "%s".)&r   Zsubstitution_defsZsubstitution_namesr   ÚsettingsÚlistr   r   Zsubstitution_referenceÚlowerr-   r/   r0   r   Zastextr1   r2   r3   r4   r5   r   rq   Ú
attributesr   rh   ÚrstripÚlstripÚdeepcopyÚ
setdefaultrs   r.   Zsubstitution_definitionZliteral_blockrw   r   ÚchildrenZReferentialZnote_refname)r   ZdefsÚnormedÚnestedrv   Z
subreflistr<   r:   r	   ÚkeyZnormed_nameZsubdefr;   r=   r>   r   rq   Zsubdef_copyZ
nested_refZnested_nameZ
ref_originr9   r   r   r    r!   —  sÎ     ÿ
ÿþÿÿ  ÿ


ÿÿÿÿÿÿ üÿþ  ÿ




zSubstitutions.applyNr"   r   r   r   r    rt   w  s   rt   c                   @   s,   e Zd ZdZdZdd„ Zdd„ Zdd„ Zd	S )
ÚTargetNotesz‚
    Creates a footnote for each external target in the text, and corresponding
    footnote references after each reference.
    i  c                 C   s$   t j| ||d |j dg ¡| _d S )N)Ú	startnodeÚclass)r   Ú__init__Údetailsr-   Úclasses)r   r   r…   r   r   r    r‡   ÿ  s    zTargetNotes.__init__c           	      C   sþ   i }g }| j  tj¡D ]v}| d¡s&q|d }g }|D ]}| | j j |g ¡¡ q6|sXq|  |d ||¡}|d |kr|||d < | 	|¡ q| j  tj
¡D ]P}| d¡s¬qœ| d¡rœ|  |d |g|¡}|d |krœ|||d < | 	|¡ qœ| j |¡ d S )Nr   r   r)   )r   r   r   r   r   r   rQ   r-   Úmake_target_footnoter.   r,   r…   r5   )	r   ÚnotesZnodelistr   r   Úrefsr   rk   r<   r   r   r    r!     s8    
ÿ

ÿzTargetNotes.applyc                 C   sZ  ||kr2|| }t |d ƒdks$t‚|d d }nlt ¡ }| j |¡}d| }d|d< |g|d< t ¡ }|tjd||d7 }||7 }| j |¡ | j 	||¡ |D ]²}t
|tjƒr´q¢tj|dd}	|	d	  | j7  < | j |	¡ | j |	¡ |j |¡d }
|	g}t | jj¡sF| jr4| dtjd
| jd¡ n| dt d
¡¡ |j |
|¡ q¢|S )Nr   r+   r   zTARGET_NOTE: ÚautorN   )r   )r	   r   r‰   ú )ÚtextZClasses)r   r   r   rk   r   r1   Z	paragraphr,   Znote_autofootnoterj   r   r   Zfootnote_referencer‰   Znote_autofootnote_refZnote_footnote_refr   rq   r   Zget_trim_footnote_ref_spacerx   re   Úinlinerh   )r   r   rŒ   r‹   rk   Zfootnote_nameZfootnote_idZfootnote_paragraphr<   Zrefnoderq   rT   r   r   r    rŠ   "  s@    
 ÿz TargetNotes.make_target_footnoteN)r#   r$   r%   r&   r'   r‡   r!   rŠ   r   r   r   r    r„   ô  s
   r„   c                   @   s   e Zd ZdZdZdd„ ZdS )ÚDanglingReferencesze
    Check for dangling references (incl. footnote & citation) and for
    unreferenced targets.
    iR  c                 C   s’   t | j| jjjƒ}| j |¡ | j tj¡D ]`}|js,| 	d¡rBq,|d rX|d d }n|d rn|d d }n|d }| jj
jd| |d q,d S )Nr)   r   r   r   r   z(Hyperlink target "%s" is not referenced.rO   )ÚDanglingReferencesVisitorr   rG   rH   Úwalkr   r   r   r7   r-   r/   Úinfo)r   Úvisitorr   rS   r   r   r    r!   P  s(    þ
ÿþzDanglingReferences.applyNr"   r   r   r   r    r‘   G  s   r‘   c                   @   s,   e Zd Zdd„ Zdd„ Zdd„ Ze ZZdS )r’   c                 C   s   t j | |¡ || _|| _d S r@   )r   ÚSparseNodeVisitorr‡   r   rH   )r   r   rH   r   r   r    r‡   n  s    z"DanglingReferencesVisitor.__init__c                 C   s   d S r@   r   )r   r9   r   r   r    Úunknown_visits  s    z'DanglingReferencesVisitor.unknown_visitc           	      C   sP  |j s| d¡sd S |d }| jj |¡}|d kr$| jD ]}||ƒr: qLq:t| jjddƒrtt|t	j
ƒrtd|_ d S || jjkrœ| jjjd|d  |d}n| jjjd|d › d|d}| j |¡}t	j|j|j|d	}z|d
 d }W n" tk
r   | j |¡}Y nX | |¡ | |¡ n(|d= ||d< | jj| j|d d|_ d S )Nr	   Z
use_bibtexFTzBDuplicate target name, cannot be used as a unique reference: "%s".rO   zUnknown target name: "z".r*   r   r   r   rD   )r8   r   r   rF   r-   rH   r   rx   r   r   Zcitation_referencer/   r0   r1   r2   r3   rl   r4   r5   r   rJ   )	r   r9   r	   r   rL   r:   r;   r=   r>   r   r   r    Úvisit_referencev  sP    


ÿÿþþ  ÿ
z)DanglingReferencesVisitor.visit_referenceN)r#   r$   r%   r‡   r—   r˜   Zvisit_footnote_referenceZvisit_citation_referencer   r   r   r    r’   l  s   &r’   N)r&   Ú__docformat__Zdocutilsr   r   Zdocutils.transformsr   r   r(   r?   rV   rW   rY   Ú	Exceptionrs   rt   r„   r‘   r–   r’   r   r   r   r    Ú<module>   s    JA 2$( ]}S%