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

�

���e�����dZddlmZddlmZddlmZddlmZddl	m
Z
mZmZdd	l
mZmZdd
lmZddlmZddlZdd
lmZmZmZerddlmZGd�de�ZGd�de�Zd�Zy)z�
This extension adds Fenced Code Blocks to Python-Markdown.

See the [documentation](https://Python-Markdown.github.io/extensions/fenced_code_blocks)
for details.
�)�annotations)�dedent�)�	Extension�)�Preprocessor)�
CodeHilite�CodeHiliteExtension�parse_hl_lines)�	get_attrs�AttrListExtension)�parseBoolValue��_escape_attrib_htmlN)�
TYPE_CHECKING�Any�Iterable)�Markdownc�$��eZdZ�fd�Zd�Z�xZS)�FencedCodeExtensionc�<��dddgi|_	t�|�di|��y)N�lang_prefix�	language-z6Prefix prepended to the language. Default: "language-"�)�config�super�__init__)�self�kwargs�	__class__s  ��A/usr/lib/python3/dist-packages/markdown/extensions/fenced_code.pyrzFencedCodeExtension.__init__'s,����K�)a�b�
���	/�
���"�6�"�c��|j|�|jjt||j	��dd�y)z9 Add `FencedBlockPreprocessor` to the Markdown instance. �fenced_code_block�N)�registerExtension�
preprocessors�register�FencedBlockPreprocessor�
getConfigs)r�mds  r!�extendMarkdownz"FencedCodeExtension.extendMarkdown.s9��
���T�"�
���!�!�"9�"�d�o�o�>O�"P�Re�gi�jr")�__name__�
__module__�__qualname__rr,�
__classcell__�r s@r!rr&s���#�kr"rc���eZdZdZej
ed�ejejzejz�Z
d�fd�Zdd�Zd	d�Z
d
d�Z�xZS)r)z& Find and extract fenced code blocks. a}
            (?P<fence>^(?:~{3,}|`{3,}))[ ]*                          # opening fence
            ((\{(?P<attrs>[^\}\n]*)\})|                              # (optional {attrs} or
            (\.?(?P<lang>[\w#.+-]*)[ ]*)?                            # optional (.)lang
            (hl_lines=(?P<quot>"|')(?P<hl_lines>.*?)(?P=quot)[ ]*)?) # optional hl_lines)
            \n                                                       # newline (end of opening fence)
            (?P<code>.*?)(?<=\n)                                     # the code block
            (?P=fence)[ ]*$                                          # closing fence
        c�n��t�|�|�||_d|_i|_d|_gd�|_y)NF)�linenums�
guess_lang�	noclasses�use_pygments)rrr�checked_for_deps�codehilite_conf�
use_attr_list�bool_options)rr+rr s   �r!rz FencedBlockPreprocessor.__init__Es9���
�������� %���/1���"���
��r"c	��|js_|jjD]?}t|t�r|j�|_t|t�s�9d|_�Ad|_dj|�}	|jj|�}|�r�ddgif\}}}}|jd�rJ|jt|jd���\}}}t|�rb|j!d�}nP|jd�r|jd�}|jd�rt#|jd��|d<|jr�|jd	r�|j%d	d�r�|jj'�}	|	j)|�|r'd
j+dj|�|	d�|	d<t-|jd
�f||	j!dd�d�|	��}
|
j/d��}n�dx}x}
x}}|r-|j0j%dd�}d|�t3|��d�}
|rdt3dj|���d�}|rdt3|��d�}|jr:|r8|j%d	d�s&djd�|j5�D��}|j7|jd
��}d|�|�d|
�|�d|�d�	}|jj8j;|�}|d|j=��d|�d||j?�d��}nn���|jAd�S)z8 Match and store Fenced Code Blocks in the `HtmlStash`. T�
N��attrsr�lang�hl_linesr7z{} {}� �	css_class�code�pygments_style�default)r@�styleF)�shebangrrz class="�"z id="c3�RK�|]\}}|dk7s�d|�dt|��d����!y�w)r7rBz="rINr)�.0�k�vs   r!�	<genexpr>z.FencedBlockPreprocessor.run.<locals>.<genexpr>�s8����+�CG�1�a�]^�bp�]p�a��s�"�%8��%;�$<�A�>�+�s�
'�'z<prez><code�>z
</code></pre>)!r8r+�registeredExtensions�
isinstancer
r*r9r
r:�join�FENCED_BLOCK_RE�search�group�handle_attrsr�len�popr�get�copy�update�formatr	�hiliterr�items�_escape�	htmlStash�store�start�end�split)r�lines�ext�text�mr@�id�classesr�local_config�	highliterrD�id_attr�	lang_attr�
class_attr�kv_pairs�prefix�placeholders                  r!�runzFencedBlockPreprocessor.runSsE���$�$��w�w�3�3�
.���c�#6�7�+.�>�>�+;�D�(��c�#4�5�)-�D�&�	
.�%)�D�!��y�y������$�$�+�+�D�1�A��,0�"�b�"�,<�)��b�'�6��7�7�7�#�*.�*;�*;�I�a�g�g�g�FV�<W�*X�'�B����7�|�&�{�{�1�~���w�w�v�� �w�w�v����w�w�z�*�-;�A�G�G�J�<O�-P��z�*��'�'�D�,@�,@��,P�U[�U_�U_�`n�pt�Uu�#'�#7�#7�#<�#<�#>�L� �'�'��/��4;�N�N��H�H�W�-�(��5�5��[�1�!+������!�!�*�.�.�/?��K�!�'�	!�I�%�+�+�E�+�:�D�BD�D�G�D�i�D�*�x��!%�������!L��&.�v�h�7J�4�7P�6Q�QR�$S�	��'/�0C�C�H�H�W�DU�0V�/W�WX�%Y�
��$)�*=�b�*A�)B�!�"D���)�)�f�V�Z�Z��X]�=^�$&�7�7�+�KQ�<�<�>�+�$�� �<�<������8�D�!�'��:�,�f�Y�K��z�QR�SW�RX�Xe�f�D�"�g�g�/�/�5�5�d�;���z����	�*�+�2�k�]�"�T�!�%�%�'�(�^�<L�M���u�v�z�z�$��r"c���d}g}i}|D]]\}}|dk(r|}�|dk(r|j|��%|dk(rt|�||<�9||jvrt|dd��||<�Y|||<�_|||fS)z6 Return tuple: `(id, [list, of, classes], {configs})` r>ri�.rAFT)�fail_on_errors�
preserve_none)�appendrr;r)rr?rirj�configsrLrMs       r!rVz$FencedBlockPreprocessor.handle_attrs�s���
�������
	�D�A�q��D�y����c�����q�!��j��+�A�.���
��d�'�'�'�+�A�e�SW�X���
����
�
	��7�G�#�#r"c��|jdd�}|jdd�}|jdd�}|jdd�}|S)	z basic html escaping �&z&amp;�<z&lt;rOz&gt;rIz&quot;)�replace)r�txts  r!r_zFencedBlockPreprocessor._escape�sG���k�k�#�w�'���k�k�#�v�&���k�k�#�v�&���k�k�#�x�(���
r")r+rrzdict[str, Any])re�	list[str]�returnr)r?zIterable[tuple[str, str]]r�z%tuple[str, list[str], dict[str, Any]])r~�strr�r�)r-r.r/�__doc__�re�compiler�	MULTILINE�DOTALL�VERBOSErSrrsrVr_r0r1s@r!r)r)5sT���0� �b�j�j���	
�	���r�y�y� �2�:�:�-��O�
�I �V$�$r"r)c��tdi|��S)Nr)r)rs r!�
makeExtensionr��s���(��(�(r")r��
__future__r�textwraprr>rr'r�
codehiliter	r
r�	attr_listrr
�utilr�serializersrr��typingrrr�markdownrrr)r�rr"r!�<module>r�sX���#���(�G�G�3�!�-�	�/�/��!�k�)�k�A�l�A�H)r"

Zerion Mini Shell 1.0