
    ̆h                        S r SSKJr  SSKJr  SSKJrJrJrJrJ	r	  SSK
r
SSKJrJrJr  SS/r\
R                   " S	\
R"                  5      rSS
 jrSS jrSS jrSS jrSS jrSSS jjrSS jrSS jrg)a  
Python-Markdown provides two serializers which render [`ElementTree.Element`][xml.etree.ElementTree.Element]
objects to a string of HTML. Both functions wrap the same underlying code with only a few minor
differences as outlined below:

1. Empty (self-closing) tags are rendered as `<tag>` for HTML and as `<tag />` for XHTML.
2. Boolean attributes are rendered as `attrname` for HTML and as `attrname="attrname"` for XHTML.
    )annotations)ProcessingInstruction)CommentElementTreeElementQName
HTML_EMPTYN)CallableLiteralNoReturnto_html_stringto_xhtml_stringz)&(?!(?:\#[0-9]+|\#x[0-9a-f]+|[0-9a-z]+);)c                ^    [        SR                  U [        U 5      R                  5      5      e)Nzcannot serialize {!r} (type {}))	TypeErrorformattype__name__texts    L/opt/services/DDDS/venv/lib/python3.13/site-packages/markdown/serializers.py_raise_serialization_errorr   :   s)    
)00tDz7J7JK
 
    c                     SU ;   a  [         R                  SU 5      n SU ;   a  U R                  SS5      n SU ;   a  U R                  SS5      n U $ ! [        [        4 a    [        U 5         g f = f)N&&amp;<&lt;>&gt;RE_AMPsubreplacer   AttributeErrorr   r   s    r   _escape_cdatar%   @   so    ) $;::gt,D$;<<V,D$;<<V,D~& )"4()s   AA A.-A.c                B    SU ;   a  [         R                  SU 5      n SU ;   a  U R                  SS5      n SU ;   a  U R                  SS5      n SU ;   a  U R                  SS5      n S	U ;   a  U R                  S	S
5      n U $ ! [        [        4 a    [        U 5         g f = f)Nr   r   r   r   r   r   "&quot;
z&#10;r    r   s    r   _escape_attribr*   R   s    )$;::gt,D$;<<V,D$;<<V,D4<<<h/D4<<<g.D~& )"4()s   A=B   BBc                    SU ;   a  [         R                  SU 5      n SU ;   a  U R                  SS5      n SU ;   a  U R                  SS5      n SU ;   a  U R                  SS5      n U $ ! [        [        4 a    [        U 5         g f = f)	Nr   r   r   r   r   r   r'   r(   r    r   s    r   _escape_attrib_htmlr,   e   s    )$;::gt,D$;<<V,D$;<<V,D4<<<h/D~& )"4()s   A%A( (BBc                   UR                   nUR                  nU[        L a  U " S[        U5      -  5        GOU[        L a  U " S[        U5      -  5        GOUc/  U(       a  U " [        U5      5        U H  n[        XU5        M     GOS n[        U[        5      (       a@  UR                  S S S:X  a"  UR                  SS  R                  SS5      u  pcO[        S5      eU " SU-   5        UR                  5       nU(       a  [        U5      nU H  u  p[        U[        5      (       a  UR                  n[        U	[        5      (       a  U	R                  n	O[        U	5      n	X:X  a  US:X  a  U " S	U	-  5        Mk  U " S
R                  X5      5        M     U(       a  U " S[        U5      -  5        US:X  a!  UR                  5       [         ;   a	  U " S5        OxU " S5        U(       a.  UR                  5       S;   a	  U " U5        OU " [        U5      5        U H  n[        XU5        M     UR                  5       [         ;  a  U " SU-   S-   5        UR"                  (       a  U " [        UR"                  5      5        g g )Nz	<!--%s-->z<?%s?>   {}z QName objects must define a tag.r   htmlz %sz {}="{}"z xmlns="%s"xhtmlz />r   )scriptstylez</)tagr   r   r%   r   _serialize_html
isinstancer   split
ValueErroritemssortedr,   r   r*   lowerr	   tail)
writeelemr   r5   r   enamespace_urir:   kvs
             r   r6   r6   v   s   
((C99D
g~kM$//0	%	%ht,,-	-%&AEf-  c5!!xx|s"%(XXab\%7%7Q%?"s !CDDcCi

5MEa''Aa''A+A.A6f.%!)$*++A12  ->-#@ABW
!:%L#J99;"55$K--.&1 yy{*,dSj3&'yymDII&' r   c                b    U c   e/ nUR                   n[        X0U5        SR                  U5      $ )N )appendr6   join)rootr   datar>   s       r   _write_htmlrJ      s4    DKKEE(774=r   c                D    [        [        U 5      R                  5       SS9$ )z9Serialize element and its children to a string of HTML5. r1   r   rJ   r   getrootelements    r   r   r      s    {7+335fEEr   c                D    [        [        U 5      R                  5       SS9$ )z9Serialize element and its children to a string of XHTML. r2   rL   rM   rO   s    r   r   r      s    {7+335gFFr   )r   strreturnr   )rS   rR   )r   rR   rS   rR   )r>   zCallable[[str], None]r?   r   r   Literal['html', 'xhtml']rS   None)r1   )rH   r   r   rT   rS   rR   )rP   r   rS   rR   )__doc__
__future__r   xml.etree.ElementTreer   r   r   r   r   r	   retypingr
   r   r   __all__compileIr!   r   r%   r*   r,   r6   rJ   r   r    r   r   <module>r_      sm   J # 7 R R 	 . ..
/	@"$$	G
)$)&)"6(rF
Gr   