%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /lib/python3/dist-packages/markdown/extensions/__pycache__/
Upload File :
Create Path :
Current File : //lib/python3/dist-packages/markdown/extensions/__pycache__/md_in_html.cpython-312.pyc

�

���e�@��
�dZddlmZddlmZddlmZddlmZddl	m
Z
dd	lmZdd
lm
Z
mZddlmcmZddlmZmZmZerdd
lmZGd�de
�ZGd�de�ZGd�de�ZGd�de
�ZGd�de�Zd�Zy)z�
An implementation of [PHP Markdown Extra](http://michelf.com/projects/php-markdown/extra/)'s
parsing of Markdown syntax in raw HTML.

See the [documentation](https://Python-Markdown.github.io/extensions/raw_html)
for details.
�)�annotations�)�	Extension�)�BlockProcessor)�Preprocessor)�RawHtmlPostprocessor)�util)�
HTMLExtractor�
blank_line_reN)�
TYPE_CHECKING�Literal�Mapping)�Markdownc���eZdZdZd�fd�Z�fd�Z�fd�Zdd�Zdd�Z�fd�Z	�fd�Z
d	�Z�fd
�Z�fd�Z
d�fd�Zd�fd
�Z�xZS)�HTMLExtractorExtraz�
    Override `HTMLExtractor` and create `etree` `Elements` for any elements which should have content parsed as
    Markdown.
    c���t|jj��|_tgd��|_tgd��|_t
�|�|g|��i|��t|j�|j|j
z|jzz
|_	|j|jz|_
y)N)�address�dd�dt�h1�h2�h3�h4�h5�h6�legend�li�p�summary�td�th)�canvas�math�option�pre�script�style�textarea)�set�block_level_elements�copy�block_level_tags�	span_tags�raw_tags�super�__init__�
empty_tags�
block_tags�span_and_blocks_tags)�self�md�args�kwargs�	__class__s    ��@/usr/lib/python3/dist-packages/markdown/extensions/md_in_html.pyr1zHTMLExtractorExtra.__init__+s���� #�B�$;�$;�$@�$@�$B� C����s�
����^�_��
�
����-�d�-�f�-��d�3�3�4�������8V�Y]�Yh�Yh�8h�i���$(�O�O�d�n�n�$D��!�c�p��g|_tj�|_g|_t
�|��y)z1Reset this instance.  Loses all unprocessed data.N)�mdstack�etree�TreeBuilder�treebuilder�mdstater0�reset�r5r9s �r:rBzHTMLExtractorExtra.reset;s+���"$��� �,�,�.���DF���
��
�r;c�x��t�|��|jr|j|jd�yy)zHandle any buffered data.rN)r0�closer=�
handle_endtagrCs �r:rEzHTMLExtractorExtra.closeBs.���
��
���<�<����t�|�|�A��/�r;c�l�|jj�}tj�|_|S)zJ Return element from `treebuilder` and reset `treebuilder` for later use. )r@rEr>r?)r5�elements  r:�get_elementzHTMLExtractorExtra.get_elementJs,���"�"�(�(�*�� �,�,�.����r;c�L�|jdd�}|dk(rd}|jr|jdnd}|dk(s
|dk(r|dk7r|}|dk(r||jvs|dk(r||jvry|dk(r||jvs|dk(r||jvry||j
vryy)	zS Return state from tag and `markdown` attribute. One of 'block', 'span', or 'off'. �markdown�0�1���N�off�span�block)�getrAr3r4r.r-)r5�tag�attrs�md_attr�parent_states     r:�	get_statezHTMLExtractorExtra.get_statePs����)�)�J��,���j� ��G�+/�<�<�t�|�|�B�'�T���5� �\�V�%;��3��"�G�
��^��t��� 6��G�#��t�/H�/H�(H���#�~�#����"7��&� �S�D�,E�,E�%E��
�D�)�)�
)��r;c���||jvr�|j�s|jr�|D��cic]\}}||�|n|��}}}d|vr@|jd�t	j
||�}t	j|dd��}n|j�}|j|d�y||jv�r|j�s|jr�|D��cic]\}}||�|n|��}}}|j||�}|js|dvr/|js#|jdd�t�	|�9||�yd|jvr||jvr|jd�|j j#|�|jj#|�||d<|j$j'||�y|jrt�	|�9||�y|j�}|j rG|j dd	k(r5|j)|j*j,j/|��n|j)|�||j0vr|j3�yycc}}wcc}}w)
NrK�unicode�html��encoding�methodT)NrOrrNrO)r2�
at_line_start�intail�popr>�Element�tostring�get_starttag_text�handle_empty_tagr-rW�inrawr=r0�handle_starttagrFrA�appendr@�start�handle_datar6�	htmlStash�store�CDATA_CONTENT_ELEMENTS�clear_cdata_mode)
r5rSrT�key�valuerH�data�state�textr9s
         �r:rfz"HTMLExtractorExtra.handle_starttages&����$�/�/�!�t�'9�'9�';�t�{�{�PU�V�*�#�u�S�5�#4�%�#�=�V�E�V��U�"��	�	�*�%��-�-��U�3���~�~�g�	�&�Q���-�-�/���!�!�$��-���$�'�'�'�T�-?�-?�-A�T�[�[�QV�V�*�#�u�S�5�#4�%�#�=�V�E�V��N�N�3��.�E��z�z�e�}�4�T�\�\��	�	�*�d�+���'��U�3��$�,�,�&�3�$�2G�2G�+G��&�&�s�+����#�#�E�*����#�#�C�(�$)��j�!�� � �&�&�s�E�2��z�z���'��U�3��-�-�/���<�<�D�L�L��$4��$=��$�$�T�W�W�%6�%6�%<�%<�T�%B�C��$�$�T�*��$�5�5�5��)�)�+�6��KW��Ws�I7�I=c	����||jv�rD|jrt�|�
|�y||jv�r�|jrb|jj�}|jj�|jj|�||k(rn
|jr�b|j�s�|j�}|jr|jdnd}|jd�s,|jd�r|jjd�|jj|jjj|��|jjd�g|_t#j$|j&|j(|j*zt-|j/|��zd�s~d|_y|j/|�}|jrG|jddk(r5|j3|jjj|��y|j3|�yyy|jrt�|�
|�y|j/|�}|jrG|jddk(r5|j3|jjj|��y|j3|�y)NrN��

�
TrO)r-rer0rFr=r`rAr@�endrI�cleandoc�endswithrgr6rjrkrqr�match�rawdata�line_offset�offset�len�get_endtag_textr_ri)r5rS�itemrHrrr9s     �r:rFz HTMLExtractorExtra.handle_endtag�s8����$�'�'�'��z�z���%�c�*�����$��l�l��<�<�+�+�-�D��L�L�$�$�&��$�$�(�(��.��s�{���l�l��|�|�"�.�.�0�G�15�
�
�4�=�=��,�2�D��=�=��0�T�]�]�4�5H��
�
�,�,�T�2��M�M�(�(����):�):�)@�)@��)I�J��M�M�(�(��0�!#�D�J�(�.�.� �L�L��)9�)9�D�K�K�)G�#�d�Nb�Nb�cf�Ng�Jh�)h�)i�j�l�'+����+�+�C�0���<�<�D�L�L��$4��$=��$�$�T�W�W�%6�%6�%<�%<�T�%B�C��$�$�T�*�l�$�4�z�z���%�c�*��+�+�C�0���<�<�D�L�L��$4��$=��$�$�T�W�W�%6�%6�%<�%<�T�%B�C��$�$�T�*r;c��||jvrn|D��cic]\}}||�|n|��}}}d|vr@|jd�tj||�}tj|dd��}n!|j�}n|j�}|j
||jj|���ycc}}w)NrKrYrZr[)�is_block)	r2r`r>rarbrcrdr6�is_block_level)r5rSrTrnrorHrps       r:�handle_startendtagz%HTMLExtractorExtra.handle_startendtag�s����$�/�/�!�PU�V�*�#�u�S�5�#4�%�#�=�V�E�V��U�"��	�	�*�%��-�-��U�3���~�~�g�	�&�Q���-�-�/���)�)�+�D����d�T�W�W�-C�-C�C�-H��I��Ws�B:c���|jrd|vrd|_|js|jst�|�|�y|j
j
|�y)NrvF)r_rer=r0rir@rp)r5rpr9s  �r:rizHTMLExtractorExtra.handle_data�sE����;�;�4�4�<��D�K��:�:�T�\�\��G���%����!�!�$�'r;c�Z��|js|jst�|�
||�y|j	�r=|r;|jd|jjj|�zdz�y|j|jjj|��y)Nrvru)	rer=r0rdr^rir6rjrk)r5rpr�r9s   �r:rdz#HTMLExtractorExtra.handle_empty_tag�s}����:�:�T�\�\��G�$�T�8�4��!�!�#��� � �����(9�(9�(?�(?��(E�!E��!N�O�� � ����!2�!2�!8�!8��!>�?r;c���|j�s|js|jrtt|�|�S|j
d�|dzS)Nz<?r)r^r_r=r0r�parse_piri�r5�ir9s  �r:r�zHTMLExtractorExtra.parse_pi�sH�������4�;�;�$�,�,����6�q�9�9�	
������1�u�r;c���|j�s|js|jrtt|�|�S|j
d�|dzS)Nz<!r)r^r_r=r0r�parse_html_declarationrir�s  �r:r�z)HTMLExtractorExtra.parse_html_declaration�sH�������4�;�;�$�,�,����D�Q�G�G�	
������1�u�r;)r6r)�return�
etree.Element)rTzMapping[str, str]r�z%Literal['block', 'span', 'off', None])r��intr�r�)�__name__�
__module__�__qualname__�__doc__r1rBrErIrWrfrFr�rirdr�r��
__classcell__)r9s@r:rr%sN����
E� �0���**,�X-+�^J�(�@���r;rc��eZdZdZdd�Zy)�HtmlBlockPreprocessorzDRemove html blocks from the text and store them for later retrieval.c���dj|�}t|j�}|j|�|j	�dj|j
�j
d�S)Nrvrt)�joinrr6�feedrErx�split)r5�lines�source�parsers    r:�runzHtmlBlockPreprocessor.run�sQ�����5�!��#�D�G�G�,�����F�������w�w�v���'�-�-�d�3�3r;N)r��	list[str]r�r�)r�r�r�r�r��r;r:r�r��s
��N�4r;r�c�(�eZdZdZdd�Zdd�Zdd�Zy)	�MarkdownInHtmlProcessorzNProcess Markdown Inside HTML Blocks which have been stored in the `HtmlStash`.c��y)NTr�)r5�parentrQs   r:�testzMarkdownInHtmlProcessor.tests��r;c��|jjdd�}|dk(�r�t|�D]}|j|��g}t	|�D]�\}}|j
s�|j
j
d�}d|_tjd�}|jj||jd��t|�}|j�|j|dz|f���|j�|D]\}}	|	D]}
|j||
��� |jr�|jj
d�}d|_tjd�}|jj||jd��t|�}|j�|D]}|jd	|��yy|d
k(r"t|�D]}|j|��y|j�d|_t!j"|j�|_t|�D]D}|j|�|j
s�!t!j"|j
�|_�Fy)a�
        Recursively parse the text content of an `etree` Element as Markdown.

        Any block level elements generated from the Markdown will be inserted as children of the element in place
        of the text content. All `markdown` attributes are removed. For any elements in which Markdown parsing has
        been disabled, the text content of it and its children are wrapped in an `AtomicString`.
        rKrOrQrvrt�divrurrrPN)�attribr`�list�parse_element_content�	enumerate�tail�rstripr>rar��parseBlocksr��reverserg�insertrrr
�AtomicString)r5rHrU�child�tails�posrQ�dummy�childrenr�r�s           r:r�z-MarkdownInHtmlProcessor.parse_element_contents0���.�.�$�$�Z��7���g���g��
2���*�*�5�1�
2�
�E�'��0�	
6�
��U��:�:�!�J�J�-�-�d�3�E�!#�E�J�!�M�M�%�0�E��K�K�+�+�E�5�;�;�v�3F�G�#�E�{�H��$�$�&��L�L�#��'�8�!4�5�	
6�
�M�M�O�"�
.�	��T� �.�D��N�N�3��-�.�
.�
�|�|����+�+�D�1��!����
�
�e�,�����'�'��u�{�{�6�/B�C���;��� � �"�%�-�E��N�N�1�e�,�-����
��g��
2���*�*�5�1�
2�
�|�|�#�!����,�,�W�\�\�:�G�L��g��
?���*�*�5�1��:�:�!%�!2�!2�5�:�:�!>�E�J�
?r;c�^�tjj|d�}|�rt|j	d��}|j
jjj|}t|tj�r�|jd�|j|�|j|�|j
jjjj|�|j
jjjj|d�yy)NrrrtTF)r
�HTML_PLACEHOLDER_RErzr��groupr�r6rj�
rawHtmlBlocks�
isinstancer>rar`r�rgr�)r5r��blocks�m�indexrHs      r:r�zMarkdownInHtmlProcessor.runKs����$�$�*�*�6�!�9�5��������
�O�E��k�k�n�n�.�.�<�<�U�C�G��'�5�=�=�1��
�
�1�
��*�*�7�3��
�
�g�&������(�(�6�6�:�:�5�A������(�(�6�6�=�=�e�R�H��r;N)r�r�rQ�strr��bool)rHr�r��None)r�r�r�r�r�r�)r�r�r�r�r�r�r�r�r;r:r�r��s��X��D?�Lr;r�c��eZdZdd�Zy)�MarkdownInHTMLPostprocessorc��t|tj�r|jj	|�St|�S)zE Override default to handle any `etree` elements still in the stash. )r�r>rar6�
serializerr�)r5rrs  r:�stash_to_stringz+MarkdownInHTMLPostprocessor.stash_to_string_s/���d�E�M�M�*��7�7�%�%�d�+�+��t�9�r;N)rrzstr | etree.Elementr�r�)r�r�r�r�r�r;r:r�r�^s��r;r�c��eZdZdZd�Zy)�MarkdownInHtmlExtensionz/Add Markdown parsing in HTML to Markdown class.c��|jjt|�dd�|jjjt|j�dd�|jjt|�dd�y)z Register extension instances. �
html_block��markdown_block�i�raw_html�N)�
preprocessors�registerr�r��blockprocessorsr��postprocessorsr�)r5r6s  r:�extendMarkdownz&MarkdownInHtmlExtension.extendMarkdownjsl��	���!�!�"7��";�\�2�N�
�	�	�!�!�*�*�#�B�I�I�.�0@�#�	
�	���"�"�#>�r�#B�J�PR�Sr;N)r�r�r�r�r�r�r;r:r�r�gs��9�
Tr;r�c��tdi|��S)Nr�)r�)r8s r:�
makeExtensionr�ws��"�,�V�,�,r;)r��
__future__rrtrr�rr�rr�r	r
�
htmlparserrr�xml.etree.ElementTreer>�ElementTree�typingr
rrrKrrr�r�r�r�r�r�r;r:�<module>r�s}���#��,�(�1��5�%�%�2�2��!�K��K�\4�L�4�]�n�]�@�"6��
T�i�
T� -r;

Zerion Mini Shell 1.0