mò hã¸Ec@sFdZdZdkZdkZdklZlZdklZl Z de fd„ƒYZ de fd„ƒYZ d e fd „ƒYZ d e fd „ƒYZ d e fd„ƒYZde fd„ƒYZdefd„ƒYZde fd„ƒYZde fd„ƒYZde fd„ƒYZdeifd„ƒYZd„ZdS(s& Transforms for resolving references. treStructuredTextN(snodessutils(sTransformErrors TransformtPropagateTargetscBstZdZdZd„ZRS(s} Propagate empty internal targets to the next element. Given the following nodes:: This is a test. PropagateTargets propagates the ids and names of the internal targets preceding the paragraph to the paragraph itself:: This is a test. icCsx |iitiƒD]ô}t|itiƒp0|idƒp |idƒp|idƒoqnt |ƒdjp t d‚|i ddƒ}|dj oet|ti ƒ ot|tiƒ pt|tiƒo*|di|dƒ|d i|d ƒt|d ƒp h|_nt|d ƒp h|_nx/|dD]#}||ii|<||i| internal external Corresponding references are linked via "refid" or resolved via "refuri":: text external i¸c Csñg}g}x>|iitiƒD]'}|idƒo|i |ƒq"q"Wx>|iiti ƒD]'}|idƒo|i |ƒqcqcWt |ƒt |ƒjo |ii i dt |ƒt |ƒfƒ}|ii|ƒ}xX|D]P}ti|i|id|ƒ}|ii|ƒ} |i| ƒ|i|ƒqëWdSnx£t||ƒD]’\}}d|_xz|idƒo|d|d indirect 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):: indirect external Once the attribute is migrated, the preexisting "refname" attribute is dropped. b) Indirect internal references:: indirect internal 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:: indirect internal iÌcCsCx<|iiD].}|ip|i|ƒn|i|ƒq WdS(N(R R tindirect_targetsRR;tresolve_indirect_targettresolve_indirect_references(R R((RR Òs   cCsè|idƒ}|djo|d}n^|iii|ƒ}|pAx6|iii D]}||ƒoPqVqVW|i |ƒdSn|ii |}|id|ƒt|tiƒo`|i oU|idƒoEt|dƒo|i|ƒdSnd|_|i|ƒ|`n|idƒo-|d|d<|idƒo |d=qÃnm|idƒo"|d|d<|ii|ƒn;|do||d<|ii|ƒn|i |ƒdS|dj o |d=nd|_dS(NRRRtmultiply_indirectiRR(RR+RRt reftarget_idR R tnameidst transformertunknown_reference_resolverstresolver_functiontnonexistent_indirect_targetRt reftargettnote_referenced_byRR R;Rtcircular_indirect_referenceR@R>thas_keyR(R RRERGRRA((RR>ØsF    .         cCsB|iii|dƒo|i|dƒn|i|dƒdS(NRs>which is a duplicate, and cannot be used as a unique referenceswhich does not exist(R R RBRJRtindirect_target_error(R R((RRFscCs|i|dƒdS(Nsforming a circular reference(R RKR(R R((RRI sc CsWd} g}|dod|dd} nx1|dD]%} |i|iii| gƒƒq8Wx1|dD]%}|i|ii i|gƒƒqlW| d|dd7} |ii i d| |d|fd |ƒ}|ii|ƒ}x^t|ƒD]P} ti| i| id |ƒ}|ii|ƒ}|i|ƒ| i|ƒqöWd |_dS( NtRs"%s" iRs (id="%s")s7Indirect hyperlink target %s refers to target "%s", %s.Rt base_nodeRi(tnamingtreflistRRRR R trefnamesR+RtrefidsR-R.t explanationR/R0R1tuniqR2R R3R4R5R6R7R8R;( R RRRROR5R1R6RR/RNR2R((RRKs*  # #    c CsÒ|idƒod}|ii}n%|idƒod}d}ndS||}xº|dD]®}|ii i |gƒ}|o|i d|ƒnxr|D]j}|ioqŸn|d=|||<|o||ƒnd|_t|tiƒo|i|ƒqŸqŸWq_Wxº|dD]®}|iii |gƒ}|o|i d|ƒnxr|D]j}|ioq\n|d=|||<|o||ƒnd|_t|tiƒo|i|ƒq\q\WqWdS( NRRRRRiRR(RRtattnameR R Rt call_methodRtattvalRRPR+RORHR2R;RR R?RRQ( R RRVRURORTR2RR((RR?%sP          ( R!R"R#R$R R>RFRIRKR?(((RR<œs 2  -   tExternalTargetscBstZdZdZd„ZRS(s¸ Given:: direct external The "refname" attribute is replaced by the direct "refuri" attribute:: direct external i€cCsÆx¿|iitiƒD]¨}|idƒo’|d}x…|dD]u}|iii |gƒ}|o|i d|ƒnx9|D]1}|i oqn|d=||d direct internal The "refname" attribute is replaced by "refid" linking to the target's "id":: direct internal RRRRiN( RRR R RBRRPR+RORHR2R;(R RROR2RR((RRYzs   (R!R"R$R RY(((RRXqs t Footnotesc BsttZdZdZeZdddddddd d d g Zd „Zd „Zd„Z d„Z d„Z d„Z RS(sè Assign numbers to autonumbered footnotes, and resolve links to footnotes, citations, and their references. Given the following ``document`` as input:: A labeled autonumbered footnote referece: An unlabeled autonumbered footnote referece: Unlabeled autonumbered footnote. 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:: A labeled autonumbered footnote referece: 2 An unlabeled autonumbered footnote referece: 1