
    hy                        S SK r S SKJrJrJrJrJrJr  SSKJ	r	  SSK
Jr  SSKJr  \(       a  SSKJr  SSKJrJr  SS	KJr  SS
KJr  S/r\ R.                  " S5      rS\-   S-   rS\-   S-   rSSS\\   SSS\4S jrSSS\\   S\	S\4S jrSSS\S\S\	S\\\4   4
S jrSSS \\\\\\4      4   S\	S\\\\\\4      4   4S! jr S"S#S\S\S\4S$ jr!S"S#S%\S\4S& jr"S"S#S%\S\S\S\4
S' jr#S)S( jr$g)*    N)TYPE_CHECKINGAnyDictListMatchUnion   )
BlockState)
LINK_LABEL)unikey)BlockParser)BaseRendererInlineState)InlineParser)Markdown	footnotesz\n{2,}z/^(?P<footnote_lead> {0,3})\[\^(?P<footnote_key>zU)]:[ \t](?P<footnote_text>[^\n]*(?:\n+|$)(?:(?P=footnote_lead) {1,3}(?! )[^\n]*\n+)*)z\[\^(?P<footnote_key>z)\]inliner   mstater   returnc                    [        UR                  S5      5      nUR                  R                  S5      nU(       a  X4;   a  UR                  R                  S5      nU(       d  / nX5;  a  UR	                  U5        XRR                  S'   UR                  SUSUR                  U5      S-   0S.5        UR                  5       $ UR                  SUR                  S	5      S
.5        UR                  5       $ )Nfootnote_keyref_footnotesr   footnote_refindex   )typerawattrstextr   )r   r   )r   groupenvgetappendappend_tokenr   end)r   r   r   keyrefnotess         lC:\Users\julio\OneDrive\Documentos\Trabajo\Ideas Frescas\venv\Lib\site-packages\mistune/plugins/footnotes.pyparse_inline_footnoter+      s    
(
)C
))--
(C
sz		k*ELL%*IIk"N3'SXS^S^_bScfgSgIhij 557N 	F1771:>?557N    blockr   c                     UR                   R                  S5      nU(       d  0 n[        UR                  S5      5      nXC;  a!  UR                  S5      X4'   X2R                   S'   UR	                  5       $ )Nr   r   footnote_text)r"   r#   r   r!   r&   )r-   r   r   r(   r'   s        r*   parse_ref_footnoter0   -   s[    
))--
(C
(
)C
~77?+%(		/"557Nr,   r'   r   c                 J   UR                   R                  S5      nU(       d  [        S5      eXA   nUR                  5       nS nUSS   H  nU(       d  M    O   U(       a  [	        U5      [	        UR                  5       5      -
  n[        R                  " S[        U5      -   S-   [        R                  S9n	U	R                  SU5      R                  5       n[        R                  U5      n
U
 Vs/ s H  nSUS	.PM
     nnOUR                  5       nSUS	./nS
XUS.S.$ s  snf )Nr   zMissing 'ref_footnotes'.r   z^ {z,})flags 	paragraph)r   r    footnote_item)r'   r   )r   childrenr   )r"   r#   
ValueError
splitlineslenlstriprecompilestrMsubstrip_PARAGRAPH_SPLITsplit)r-   r'   r   r   r(   r    linessecond_linespacespatternitemssr6   s                r*   parse_footnote_itemrI   9   s
   
))--
(C3448DOOEKQRy; ! [!C(:(:(<$==**Vc&k1E9F{{2t$**, &&t,>CDe[!4eDzz|($78#Z_D`aa	 Es   0D mdr   resultc           
         UR                   R                  S5      nU(       d  U$ [        U5       VVs/ s H  u  pE[        U R                  XTS-   U5      PM!     nnn[        5       nSUS./Ul        U R                  U5      nX-   $ s  snnf )Nr   r   )r   r6   )r"   r#   	enumeraterI   r-   r
   tokensrender_state)rJ   rK   r   r)   ikr6   outputs           r*   md_footnotes_hookrS   Q   s     IIMM+&EKTUZK[\K[41#BHHaQ>K[H\LE(h?@EL__U#F?	 ]s   &Brendererr   c                 J    [        U5      nSU-   S-   nUS-   U-   S-   U-   S-   $ )Nz$<sup class="footnote-ref" id="fnref-">z<a href="#fn-z
</a></sup>)r=   )rT   r'   r   rP   htmls        r*   render_footnote_refrX   _   s9    E
A1A5<D/!A%,q0<??r,   r    c                     SU-   S-   $ )Nz!<section class="footnotes">
<ol>
z</ol>
</section>
 )rT   r    s     r*   render_footnotesr[   e   s    047:OOOr,   c                 v    [        U5      nSU-   S-   nUR                  5       S S U-   S-   nSU-   S-   U-   S-   $ )Nz<a href="#fnref-z" class="footnote">&#8617;</a>z</p>z<li id="fn-rV   z</li>
)r=   rstrip)rT   r    r'   r   rP   backs         r*   render_footnote_itemr`   i   sQ    E
A!$DDD;;="$v-D1t#d*Y66r,   c                    U R                   R                  S[        [        SS9  U R                  R                  S[
        [        SS9  U R                  R                  [        5        U R                  (       a|  U R                  R                  S:X  aa  U R                  R                  S[        5        U R                  R                  S[        5        U R                  R                  S	[        5        g
g
g
)aX  A mistune plugin to support footnotes, spec defined at
https://michelf.ca/projects/php-markdown/extra/#footnotes

Here is an example:

.. code-block:: text

    That's some text with a footnote.[^1]

    [^1]: And that's the footnote.

It will be converted into HTML:

.. code-block:: html

    <p>That's some text with a footnote.<sup class="footnote-ref" id="fnref-1"><a href="#fn-1">1</a></sup></p>
    <section class="footnotes">
    <ol>
    <li id="fn-1"><p>And that's the footnote.<a href="#fnref-1" class="footnote">&#8617;</a></p></li>
    </ol>
    </section>

:param md: Markdown instance
footnotelink)beforeref_footnoteref_linkrW   r   r5   r   N)r   registerINLINE_FOOTNOTEr+   r-   REF_FOOTNOTEr0   after_render_hooksr$   rS   rT   NAMErX   r`   r[   )rJ   s    r*   r   r   p   s    2 II	   HH	     !23	{{r{{''61
^-@A
_.BC
[*:; 2{r,   )rJ   r   r   N)%r;   typingr   r   r   r   r   r   corer
   helpersr   utilr   block_parserr   r   r   inline_parserr   markdownr   __all__r<   rA   ri   rh   r=   intr+   r0   rI   rS   rX   r[   r`   r   rZ   r,   r*   <module>ru      s   	 ? ?    *0,#-::i( )*-		  +Z7&@. U3Z  Z]  	m 	c
 	: 	RU 	b} b3 bs b: bZ^_bdg_gZh b0!#tDcN';";<EO
3T#s(^$$%@. @s @3 @3 @P~ PS PS P7> 7 73 7s 7WZ 7*<r,   