o
    \)                     @   s  d dl Z d dlZd dlZzd dlmZ W n   i ZY ddlmZ dZzeeddZW n   Y h dZ	dZ
ed	Ze ed
 e je jB Ze de je jB Ze de d e je jB Ze de d
 e je jB Ze ed e je jB Ze de je jB e jB Ze de je jB e jB Ze de je jB e jB Zd ddZd!ddZdd Zdd Zdd Zdd Zdd ZdS )"    N)settings   )
force_text)prescripttextareaEXCLUDE_TAGS_FROM_MINIFYING>   abiqsubremrprtbdibdodeldfninskbdsubsupvarwbrabbrcitecodedatamarkrubysampspantimesmallstrongTu   ((?=\s)[^ ])+z^\n$^z+$z\[if .*\]>.*<!\[endif\]z(\[if .*\]>)\s+z\s+(<!\[endif\])html5libc                 C   s@   t | } t| |}t||}tdu rtdtjj_	t
|S )NT>)r   bs4BeautifulSoupspace_minifyFOLD_DOCTYPEsixr   elementDoctypeSUFFIX	text_type)	html_codeignore_commentsparsersoup	mini_soup r:   E/var/www/html/kck/venv/lib/python3.10/site-packages/htmlmin/minify.pyhtml_minify4   s   

r<   c                 C   sF  t | jtv r	dS t| dr| jD ]}t|| qt| rt| skt	d| j
}t| \}}|r9|r9t	d|}nt	d|}|rHt	d|}nt	d|}|rWt	d|}nt	d|}t	d|}| j
| | S t| rt	d| j
}t	d|}t	d|}tj|}| j
| | S |du rt| r| j
td | S )a   recursive function to reduce space characters in html code.

    :param soup: a BeautifulSoup of the code to reduce
    :type soup: bs4.BeautifulSoup
    :param ignore_comments: whether or not to keep comments in the
                            result
    :type ignore_comments: bool
    Nchildren  z\1T)strnameEXCLUDE_TAGShasattrr=   r.   	is_navstr	is_prestrre_multi_spacer   string	is_inflowre_only_spacere_start_spacere_end_spacere_single_nlreplace_withis_cond_commentre_cond_comment_start_spacere_cond_comment_end_spacer,   r1   Comment
is_commentr0   r   )r8   r6   child
new_string	prev_flow	next_flownew_commentr:   r:   r;   r.   >   sB   


r.   c                 C      t | tjjS )ztest whether an element is a NavigableString or not, return a
    boolean.

    :param soup: a BeautifulSoup of the code to reduce
    :type soup: bs4.BeautifulSoup
    )
isinstancer,   r1   NavigableStringr8   r:   r:   r;   rD         rD   c                 C   rX   )ztest whether an element is a PreformattedString or not, return a
    boolean.

    :param soup: a BeautifulSoup of the code to reduce
    :type soup: bs4.BeautifulSoup
    )rY   r,   r1   PreformattedStringr[   r:   r:   r;   rE      r\   rE   c                 C   s   t | tjjot| j S )ztest whether an element is a Comment, return a boolean.

    :param soup: a BeautifulSoup of the code to reduce
    :type soup: bs4.BeautifulSoup
    rY   r,   r1   rQ   re_cond_commentsearchrG   r[   r:   r:   r;   rR      s   rR   c                 C   s   t | tjjot| jS )ztest whether an element is a conditional comment, return a
    boolean.

    :param soup: a BeautifulSoup of the code to reduce
    :type soup: bs4.BeautifulSoup
    r^   r[   r:   r:   r;   rN      s   
rN   c                 C   sN   | j dur| j jtv rd}nd}| jdur!| jjtv r!d}||fS d}||fS )aV  test whether an element belongs to a text flow, returns a tuple
    of two booleans describing the flow around the element. The first
    boolean represents the flow before the element, the second boolean
    represents the flow after the element.

    :param soup: a BeautifulSoup of the code to reduce
    :type soup: bs4.BeautifulSoup
    NTF)previous_siblingrA   	TEXT_FLOWnext_sibling)r8   rU   rV   r:   r:   r;   rH      s   
	
rH   )Tr*   )T) rer0   r,   django.confr   utilr   rB   getattrrb   r/   r   re_spacecompile	MULTILINEUNICODErF   rL   rI   rJ   rK   DOTALLr_   rO   rP   r<   r.   rD   rE   rR   rN   rH   r:   r:   r:   r;   <module>   sJ   



B


