%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__/tables.cpython-312.pyc

�

���e%"���dZddlmZddlmZddlmZddlmcm	Zddl
Z
ddlmZm
Z
mZerdd	lmZdZdZdZGd
�de�ZGd�d
e�Zd�Zy)z�
Added parsing of tables to Python-Markdown.

See the [documentation](https://Python-Markdown.github.io/extensions/tables)
for details.
�)�annotations�)�	Extension�)�BlockProcessorN)�
TYPE_CHECKING�Any�Sequence)�blockparserc���eZdZdZej
d�Zej
d�Zd�fd�Zdd�Z	d
d�Z
dd�Zdd�Zdd	�Z
dd
�Z�xZS)�TableProcessorz Process Tables. z"(?:(\\\\)|(\\`+)|(`+)|(\\\|)|(\|))z(?<!\\)(?:\\\\)*\|$c�N��d|_d|_||_t�|�|�y)NF�)�border�	separator�config�super�__init__)�self�parserr�	__class__s   ��</usr/lib/python3/dist-packages/markdown/extensions/tables.pyrzTableProcessor.__init__,s%���"'���(*������
���� �c�"�d}|jd�D�cgc]}|jd���}}t|�dkD�rK|d}t|_|jd�r|xjtzc_|jj|��|xjtzc_|j|�}t|�}|dkD}|se|dk(r`|jrTtdt|��D]<}||jd�}|s |jj||�du}|r�<n|rS|j|d�}t|�|k(xr&tdj|��td	�k}|r||_|Scc}w)
z�
        Ensure first two rows (column header and separator row) are valid table rows.

        Keep border check and separator row do avoid repeating the work.
        F�
� rr�|Nrz|:- )�split�strip�len�	PIPE_NONEr�
startswith�	PIPE_LEFT�
RE_END_BORDER�search�
PIPE_RIGHT�
_split_row�range�set�joinr)	r�parent�block�is_table�row�rows�header0�row0_len�indexs	         r�testzTableProcessor.test3se����*/�+�+�d�*;�<�3��	�	�#��<��<��t�9�q�=��1�g�G�#�D�K��!�!�#�&����y�(���!�!�(�(��1�=����z�)���/�/�'�*�C��3�x�H��!�|�H���A�
�$�+�+�"�1�c�$�i�0��E�#�E�{�5�5�c�:�H�#�#'�#5�#5�#<�#<�T�%�[�#I�QU�#U��#�����o�o�d�1�g�.����H��0�V�c�"�'�'�#�,�6G�3�v�;�6V���%(�D�N����7=s�Fc�2�|jd�jd�}|djd�}t|�dkrgn|dd}g}|jD]�}|jd�}|jd�r#|j
d�r|jd��H|jd�r|jd	��k|j
d�r|jd
���|jd���tj|d�}tj|d�}	|j||	|�tj|d
�}
t|�dk(r|j|
|�y|D]$}|j|jd�|
|��&y)z& Parse a table block and build table. rrr�rN�:�center�left�right�table�thead�tbody)�poprrr rr"�endswith�append�etree�
SubElement�
_build_row�_build_empty_row)rr+�blocksr,�headerr/�align�cr:r;r<r.s            r�runzTableProcessor.runWsQ���
�
�1�
�#�#�D�)���q�����$����Z�!�^�r��q�r���#%�����		#�A������A��|�|�C� �Q�Z�Z��_����X�&����c�"����V�$����C�����W�%����T�"�		#�� � ���1��� � ���0�������u�-�� � ���0���t�9��>��!�!�%��/��
>������	�	�#���u�=�
>rc��tj|d�}t|�}|rtj|d�|dz}|r�yy)zBuild an empty row.�tr�tdrN)r@rAr )rr+rFrJ�counts     rrCzTableProcessor._build_empty_rowvs>��
�
�
�f�d�
+���E�
������R��&��Q�J�E�rc��tj|d�}d}|jdk(rd}|j|�}t	|�D]p\}}tj||�}		||jd�|	_|s�9|jdr|	jd|��[|	jd	d
|�d���ry#t$r
d|	_Y�PwxYw)
z) Given a row of text, build table cells. rJrKr;�thrr�use_align_attributerF�styleztext-align: �;N)
r@rA�tagr'�	enumerater�text�
IndexErrorrr))
rr.r+rFrJrR�cells�i�arGs
          rrBzTableProcessor._build_row~s���
�
�
�f�d�
+�����:�:�� ��C�����$���e�$�
	8�D�A�q�� � ��S�)�A�
��q�����,�����;�;�4�5��E�E�'�1�%��E�E�'�\�!��A�#6�7�
	8���
����
�s�#B:�:C
�C
c��|jr2|jd�r|dd}|jjd|�}|j	|�S)z) split a row of text into list of cells. rrNr)rr"r$�sub�_split)rr.s  rr'zTableProcessor._split_row�sG���;�;��~�~�c�"��!�"�g���$�$�(�(��S�1�C��{�{�3��rc��g}g}g}g}g}g}|jj|�D�]}|jd�rb|jt	|jd��dz
�|j|jd�|j
d�dz
df��w|jd�r_|jt	|jd���|j|jd�|j
d�dz
df���|jd�s��|j|jd����d}	t	|�}
|	|
krd	||	||	dz
}|dk(rt�||	dzdj|�dz}|j||	d||	|zdf�|	|dzz
}	|	|
kr�d|D]A}
d}|D]$}|
|dkrn|d|
cxkr	|dks�n�"d}n|r�1|j|
��Cd}	|D]}
|j||	|
�|
dz}	�|j||	d�|S#t$r|	dz
}	Y��wxYw)	z: split a row of text with some code into a list of cells. rrr5r�NFT)	�
RE_CODE_PIPES�finditer�groupr?r �start�end�
ValueErrorr2)rr.�elements�pipes�tics�
tic_points�
tic_region�
good_pipes�m�pos�tic_len�tic_sizer2�pipe�	throw_out�regions                rr[zTableProcessor._split�sj���������
��
��
��#�#�,�,�S�1�	)�A��w�w�q�z����C�����
�O�a�/�0��!�!�1�7�7�1�:�q�u�u�Q�x�!�|�Q�"?�@���������C�����
�O�,��!�!�1�7�7�1�:�q�u�u�Q�x�!�|�Q�"?�@���������Q�W�W�Q�Z�(�!	)�,���d�)���G�m�
���9�z�#��q�'9�9���q�=�$�$��S�1�W�X��,�,�X�6��:���!�!�:�c�?�1�#5�z�#��+�7N�q�7Q�"R�S��u�q�y� ���G�m� �	(�D��I�$�
���&��)�#���A�Y�$�3�&��)�3� $�I��
���!�!�$�'�	(����	�D��O�O�C��D�M�*���(�C�	�	����C�D�	�"����7�
��q���
�s�AH8�8I	�I	)rzblockparser.BlockParserrzdict[str, Any])r+�
etree.Elementr,�str�return�bool)r+rqrD�	list[str]rs�None)r+rqrF�Sequence[str | None]rsrv)r.rrr+rqrFrwrsrv)r.rrrsru)�__name__�
__module__�__qualname__�__doc__�re�compiler^r$rr3rHrCrBr'r[�
__classcell__�rs@rr
r
&sM�����B�J�J�D�E�M��B�J�J�5�6�M�!�"�H>�>�8�* �Frr
c�(��eZdZdZ�fd�Zd�Z�xZS)�TableExtensionz Add tables to Markdown. c�<��dddgi|_	t�|�di|��y)NrOFz-True to use align attribute instead of style.�)rrr)r�kwargsrs  �rrzTableExtension.__init__�s,���!�E�+Z�#[�
���	/�
���"�6�"rc���d|jvr|jjd�t|j|j	��}|jj
j
|dd�y)z7 Add an instance of `TableProcessor` to `BlockParser`. rr:�KN)�
ESCAPED_CHARSr?r
r�
getConfigs�blockprocessors�register)r�md�	processors   r�extendMarkdownzTableExtension.extendMarkdown�sW���b�&�&�&����#�#�C�(�"�2�9�9�d�o�o�.?�@�	�
�	�	�!�!�*�*�9�g�r�Br)rxryrzr{rr�r~rs@rr�r��s���#�#�Crr�c��tdi|��S)Nr�)r�)r�s r�
makeExtensionr��s���#�F�#�#r)r{�
__future__rrrr�r�xml.etree.ElementTreer@�ElementTreer|�typingrr	r
rr!r#r&r
r�r�r�rr�<module>r�s[���#��,�%�%�	�/�/���
�	�
�	�
�
�{�^�{�|C�Y�C�&$r

Zerion Mini Shell 1.0