
    gi                       d Z ddlmZ ddlZddlmZmZmZmZ ddl	m
Z
 ddlmZ erddlmZ dd	lmZ d
Z G d de          Z G d de          Z G d de          Z G d de          Z G d de          Z G d de          Z G d de          Z G d de          Z G d de          Z G d de          Z G d d e          ZdS )!z
Inline(span) level elements
    )annotationsN)TYPE_CHECKINGIteratorPatternSequence   )patterns)Element)_Match)Source)
	LineBreakLiteral
InlineHTMLCodeSpanEmphasisStrongEmphasisLinkImageAutoLinkRawTextc                  d    e Zd ZU dZdZdZded<   dZdZdZ	dZ
erded	<   ddZedd            ZdS )InlineElementz,Any inline element should inherit this class    zPattern[str] | strpatternFr   zstr | Sequence[Element]childrenmatchr   returnNonec                V    | j         s!|                    | j                  | _        dS dS )z)Parses the matched object into an elementN)parse_childrengroupparse_groupr   selfr   s     d/var/www/development/aibuddy-work/election-extract/venv/lib/python3.11/site-packages/marko/inline.py__init__zInlineElement.__init__3   s1    " 	:!KK(899DMMM	: 	:    textstrsourcer   Iterator[_Match]c                   t          | j        t                    rt          j        | j                  | _        | j                            |          S )zIThis method should return an iterable containing matches of this element.)
isinstancer   r*   recompilefinditer)clsr)   r+   s      r&   findzInlineElement.find8   sA     ck3'' 	2*S[11CK{##D)))r(   Nr   r   r   r   )r)   r*   r+   r   r   r,   )__name__
__module____qualname____doc__priorityr   __annotations__r!   r#   virtualoverrider   r'   classmethodr3    r(   r&   r   r      s         66 H"$G$$$$NK GH *)))): : : :
 * * * [* * *r(   r   c                  N    e Zd ZdZdZ ej        d          Zed	d            Z	dS )
r   z/Literal escapes need to be parsed at the first.   z,\\([!"#\$%&\'()*+,\-./:;<=>?@\[\\\]^_`{|}~])r)   r*   r   c                8    | j                             d|          S )Nz\1)r   sub)r2   r)   s     r&   strip_backslashzLiteral.strip_backslashF   s    {ud+++r(   N)r)   r*   r   r*   )
r5   r6   r7   r8   r9   r/   r0   r   r=   rC   r>   r(   r&   r   r   @   sO        99HbjHIIG, , , [, , ,r(   r   c                  "    e Zd ZdZdZdZd
dZd	S )r   z0Line breaks:

    Soft: '
'
    Hard: '  
'
       z( *|\\)\n(?!\Z)r   r   r   r   c                p    |                     d                              d           | _        d| _        d S )Nr   )z  \
)r"   
startswithsoftr   r$   s     r&   r'   zLineBreak.__init__U   s/    A11,???	r(   Nr4   )r5   r6   r7   r8   r9   r   r'   r>   r(   r&   r   r   K   s>          H G     r(   r   c            	      d    e Zd ZdZ ej        dej        dej        dej        d          Z	dS )r   r@   z(<z(?:z
)* */?>|</zY *>|<!--(?:>|->|[\s\S]*?-->)|<\?[\s\S]*?\?>|<![A-Z]+ +[\s\S]*?>|<!\[CDATA\[[\s\S]*?\]\]>)N)
r5   r6   r7   r9   r/   r0   r	   tag_name	attributer   r>   r(   r&   r   r   Z   sR        Hbjj h000(2C2C2C	E GGGr(   r   c                      e Zd ZdZdZdZdS )r   z Strong emphasis: **sample text**TNr5   r6   r7   r8   r;   r!   r>   r(   r&   r   r   g   s        **GNNNr(   r   c                      e Zd ZdZdZdZdS )r   zEmphasis: *sample text*TNrO   r>   r(   r&   r   r   n   s        !!GNNNr(   r   c                  "    e Zd ZdZdZdZd	dZdS )
r   zLink: [text](/link/destination)Tr   r   r   r   c                   |                     d          ra|                     d          d         dk    rB|                     d          d         dk    r#|                     d          dd         | _        n|                     d          pd| _        t                              | j                  | _        |                     d          r5t                              |                     d          dd                   nd | _        d S 	NrE   r   <>r   r      r"   destr   rC   titler$   s     r&   r'   zLink.__init__{       ;;q>> 	-ekk!nnQ/3665;;q>>";MQT;T;TAqt,DIIA,"DI++DI66	=B[[^^UG##EKKNN1R4$8999QU 	


r(   Nr4   r5   r6   r7   r8   r;   r!   r'   r>   r(   r&   r   r   u   s8        ))GN
 
 
 
 
 
r(   r   c                  "    e Zd ZdZdZdZd	dZdS )
r   zImage: ![alt](/src/address)Tr   r   r   r   c                   |                     d          ra|                     d          d         dk    rB|                     d          d         dk    r#|                     d          dd         | _        n|                     d          pd| _        t                              | j                  | _        |                     d          r5t                              |                     d          dd                   nd | _        d S rS   rX   r$   s     r&   r'   zImage.__init__   r[   r(   Nr4   r\   r>   r(   r&   r   r      s8        %%GN
 
 
 
 
 
r(   r   c                  >    e Zd ZdZdZ ej        d          Zd
dZd	S )r   zInline code span: `code sample`r@   z&(?<!`)(`+)(?!`)([\s\S]+?)(?<!`)\1(?!`)r   r   r   r   c                   |                     d                              dd          | _        | j                                        r=| j        d         | j        d         cxk    rdk    rn d S | j        dd         | _        d S d S d S )NrE   rH    r   rU   r   )r"   replacer   stripr$   s     r&   r'   zCodeSpan.__init__   s    A..tS99=   	0T]1%5r9J%Q%Q%Q%Qc%Q%Q%Q%Q%Q%Q M!B$/DMMM	0 	0%Q%Qr(   Nr4   )	r5   r6   r7   r8   r9   r/   r0   r   r'   r>   r(   r&   r   r      sE        ))HbjBCCG0 0 0 0 0 0r(   r   c                  `    e Zd ZdZdZ ej        dej         dej	         d          Z
dd
ZdS )r   zAutolinks: <http://example.org>r@   z<(|z)>r   r   r   r   c                    |                     d          | _        t          j        t          j        | j                  rd| j        z   | _        t          |                     d                    g| _        d| _        d S )Nr   zmailto:r   )	r"   rY   r/   r   r	   emailr   r   rZ   r$   s     r&   r'   zAutoLink.__init__   s`    KKNN	8HNDI.. 	.!DI-DI Q001


r(   Nr4   )r5   r6   r7   r8   r9   r/   r0   r	   urirg   r   r'   r>   r(   r&   r   r      s\        ))Hbj@x|@@hn@@@AAG     r(   r   c                  0    e Zd ZU dZdZerded<   ddd
ZdS )r   zIThe raw text is the fallback for all holes that doesn't match any others.Tr*   r   r   escapeboolr   r   c                "    || _         || _        d S )N)r   rj   )r%   r   rj   s      r&   r'   zRawText.__init__   s    r(   N)T)r   r*   rj   rk   r   r   )r5   r6   r7   r8   r;   r   r:   r'   r>   r(   r&   r   r      sK         SSG       r(   r   )r8   
__future__r   r/   typingr   r   r   r   r   r	   elementr
   inline_parserr   r+   r   __all__r   r   r   r   r   r   r   r   r   r   r   r>   r(   r&   <module>rr      s    # " " " " " 				 = = = = = = = = = = = =             %%%%%%* * * * *G * * *B, , , , ,m , , ,       
 
 
 
 
 
 
 
    ]       }   
 
 
 
 
= 
 
 
"
 
 
 
 
M 
 
 
"	0 	0 	0 	0 	0} 	0 	0 	0    }   	 	 	 	 	m 	 	 	 	 	r(   