%PDF- %PDF-
Mini Shell

Mini Shell

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

�

���eWS��&�ddlmZddlZddlZddlZddlZddlmZmZm	Z	m
Z
mZmZm
Z
ddlmZddlmZddlmZddlmZdd	lmZdd
lmZddlmZddlmZmZdd
lmZerddl m!Z!gd�Z"ejFd�Z$Gd�d�Z%	dd�Z&dd�Z'y)�)�annotationsN)�
TYPE_CHECKING�Any�BinaryIO�Callable�ClassVar�Mapping�Sequence�)�util)�build_preprocessors)�build_block_parser)�build_treeprocessors)�build_inlinepatterns)�build_postprocessors)�	Extension)�to_html_string�to_xhtml_string)�BLOCK_LEVEL_ELEMENTS)�Element)�Markdown�markdown�markdownFromFile�MARKDOWNc��eZdZUdZdZeed�Zded<	d�Z	dd�Z
						dd�Zdd	�Zdd
�Z
dd�Zdd�Zdd
�Zdd�Z			d							dd�Zy)ra	
    A parser which converts Markdown to HTML.

    Attributes:
        Markdown.tab_length (int): The number of spaces which correspond to a single tab. Default: `4`.
        Markdown.ESCAPED_CHARS (list[str]): List of characters which get the backslash escape treatment.
        Markdown.block_level_elements (list[str]): List of HTML tags which get treated as block-level elements.
            See [`markdown.util.BLOCK_LEVEL_ELEMENTS`][] for the full list of elements.
        Markdown.registeredExtensions (list[Extension]): List of extensions which have called
            [`registerExtension`][markdown.Markdown.registerExtension] during setup.
        Markdown.doc_tag (str): Element used to wrap document. Default: `div`.
        Markdown.stripTopLevelTags (bool): Indicates whether the `doc_tag` should be removed. Default: 'True'.
        Markdown.references (dict[str, tuple[str, str]]): A mapping of link references found in a parsed document
             where the key is the reference name and the value is a tuple of the URL and title.
        Markdown.htmlStash (util.HtmlStash): The instance of the `HtmlStash` used by an instance of this class.
        Markdown.output_formats (dict[str, Callable[xml.etree.ElementTree.Element]]): A mapping of known output
             formats by name and their respective serializers. Each serializer must be a callable which accepts an
            [`Element`][xml.etree.ElementTree.Element] and returns a `str`.
        Markdown.output_format (str): The output format set by
            [`set_output_format`][markdown.Markdown.set_output_format].
        Markdown.serializer (Callable[xml.etree.ElementTree.Element]): The serializer set by
            [`set_output_format`][markdown.Markdown.set_output_format].
        Markdown.preprocessors (util.Registry): A collection of [`preprocessors`][markdown.preprocessors].
        Markdown.parser (blockparser.BlockParser): A collection of [`blockprocessors`][markdown.blockprocessors].
        Markdown.inlinePatterns (util.Registry): A collection of [`inlinepatterns`][markdown.inlinepatterns].
        Markdown.treeprocessors (util.Registry): A collection of [`treeprocessors`][markdown.treeprocessors].
        Markdown.postprocessors (util.Registry): A collection of [`postprocessors`][markdown.postprocessors].

    �div)�html�xhtmlz-ClassVar[dict[str, Callable[[Element], str]]]�output_formatsc���|jdd�|_gd�|_	tj�|_g|_d|_d|_|j�i|_
tj�|_
|j|jdg�|jdi���|j|jd	d
��|j!�y)a�
        Creates a new Markdown instance.

        Keyword Arguments:
            extensions (list[Extension | str]): A list of extensions.

                If an item is an instance of a subclass of [`markdown.extensions.Extension`][],
                the instance will be used as-is. If an item is of type `str`, it is passed
                to [`build_extension`][markdown.Markdown.build_extension] with its corresponding
                `extension_configs` and the returned instance  of [`markdown.extensions.Extension`][]
                is used.
            extension_configs (dict[str, dict[str, Any]]): Configuration settings for extensions.
            output_format (str): Format of output. Supported formats are:

                * `xhtml`: Outputs XHTML style tags. Default.
                * `html`: Outputs HTML style tags.
            tab_length (int): Length of tabs in the source. Default: `4`

        �
tab_length�)�\�`�*�_�{�}�[�]�(�)�>�#�+�-�.�!�T�
extensions�extension_configs)r4�configs�
output_formatrN)�getr!�
ESCAPED_CHARSr�copy�block_level_elements�registeredExtensions�docType�stripTopLevelTags�build_parser�
referencesr�	HtmlStash�	htmlStash�registerExtensions�set_output_format�reset)�self�kwargss  �//usr/lib/python3/dist-packages/markdown/core.py�__init__zMarkdown.__init__Xs���* &�z�z�,��:���)
���	M�/C�/H�/H�/J��!�57��!����'+�������68���)-���)9������6�:�:�l�B�+G�(.�
�
�3F��(K�	 �	M����v�z�z�/�7�C�D��
�
��c��t|�|_t|�|_t	|�|_t
|�|_t|�|_	|S)a0
        Build the parser from the various parts.

        Assigns a value to each of the following attributes on the class instance:

        * **`Markdown.preprocessors`** ([`Registry`][markdown.util.Registry]) -- A collection of
          [`preprocessors`][markdown.preprocessors].
        * **`Markdown.parser`** ([`BlockParser`][markdown.blockparser.BlockParser]) -- A collection of
          [`blockprocessors`][markdown.blockprocessors].
        * **`Markdown.inlinePatterns`** ([`Registry`][markdown.util.Registry]) -- A collection of
          [`inlinepatterns`][markdown.inlinepatterns].
        * **`Markdown.treeprocessors`** ([`Registry`][markdown.util.Registry]) -- A collection of
          [`treeprocessors`][markdown.treeprocessors].
        * **`Markdown.postprocessors`** ([`Registry`][markdown.util.Registry]) -- A collection of
          [`postprocessors`][markdown.postprocessors].

        This method could be redefined in a subclass to build a custom parser which is made up of a different
        combination of processors and patterns.

        )
r
�
preprocessorsr�parserr�inlinePatternsr�treeprocessorsr�postprocessors)rFs rHr?zMarkdown.build_parser�sI��*1��6���(��.���2�4�8���2�4�8���2�4�8����rJc	�
�|D]�}t|t�r"|j||j|i��}t|t�rV|j|�tjd|jj�d|jj�d����|���tdj|jj|jjtjtj���|S)a�
        Load a list of extensions into an instance of the `Markdown` class.

        Arguments:
            extensions (list[Extension | str]): A list of extensions.

                If an item is an instance of a subclass of [`markdown.extensions.Extension`][],
                the instance will be used as-is. If an item is of type `str`, it is passed
                to [`build_extension`][markdown.Markdown.build_extension] with its corresponding `configs` and the
                returned instance  of [`markdown.extensions.Extension`][] is used.
            configs (dict[str, dict[str, Any]]): Configuration settings for extensions.

        zSuccessfully loaded extension "r1z".z*Extension "{}.{}" must be of type: "{}.{}")
�
isinstance�str�build_extensionr8r�extendMarkdown�logger�debug�	__class__�
__module__�__name__�	TypeError�format)rFr4r6�exts    rHrCzMarkdown.registerExtensions�s���$�	�C��#�s�#��*�*�3����C��0D�E���#�y�)��"�"�4�(�����}�}�/�/����1G�1G�I�����@�G�G��
�
�0�0�#�-�-�2H�2H�!�,�,�i�.@�.@����	� �rJc��t|�}tj�D�cgc]}|j|k(s�|��}}|r|dj	�}|d
i|��Sd|vr|jdd�n|df\}}	t
j|�}tjd|z�|rt||�d
i|��S	|jd
i|��Scc}w#t$r#}d|z}	|	f|jddz|_�d}~wwxYw#t$r5}|jd}	d|�d	|	��}	|	f|jddz|_�d}~wwxYw)a�
        Build extension from a string name, then return an instance using the given `configs`.

        Arguments:
            ext_name: Name of extension as a string.
            configs: Configuration settings for extension.

        Returns:
            An instance of the extension with the given configuration settings.

        First attempt to load an entry point. The string name must be registered as an entry point in the
        `markdown.extensions` group which points to a subclass of the [`markdown.extensions.Extension`][] class.
        If multiple distributions have registered the same name, the first one found is returned.

        If no entry point is found, assume dot notation (`path.to.module:ClassName`). Load the specified class and
        return an instance. If no class is specified, import the module and call a `makeExtension` function and return
        the [`markdown.extensions.Extension`][] instance returned by that function.
        r�:rr3z,Successfully imported extension module "%s".zFailed loading extension "%s".NzFailed to initiate extension 'z': �)�dictr�get_installed_extensions�name�load�split�	importlib�
import_modulerVrW�ImportError�args�getattr�
makeExtension�AttributeError)
rF�ext_namer6�ep�entry_pointsr]�
class_name�module�e�messages
          rHrTzMarkdown.build_extension�s\��&�w�-��%)�%B�%B�%D�\�r����S[�H[��\��\���q�/�&�&�(�C��>��>�!�:=���x�~�~�c�1�5�x�Y[�n���*�	��,�,�X�6�F��L�L�>��I�
��.�7�6�:�.�9��9�9�
�+�v�+�+�6�g�6�6��1]���	�6��A�G��Z�!�&�&���*�,�A�F���	��"�
��&�&��)��(0�'�;��!��a�f�f�Q�R�j�0�����
�s:�C�C�8-C�:D�	C=�C8�8C=�	D>�	0D9�9D>c�<�|jj|�|S)a�
        Register an extension as having a resettable state.

        Arguments:
            extension: An instance of the extension to register.

        This should get called once by an extension during setup. A "registered" extension's
        `reset` method is called by [`Markdown.reset()`][markdown.Markdown.reset]. Not all extensions have or need a
        resettable state, and so it should not be assumed that all extensions are "registered."

        )r<�append�rF�	extensions  rH�registerExtensionzMarkdown.registerExtension�s��	
�!�!�(�(��3��rJc���|jj�|jj�|jD]}t|d�s�|j��!|S)z�
        Resets all state variables to prepare the parser instance for new input.

        Called once upon creation of a class instance. Should be called manually between calls
        to [`Markdown.convert`][markdown.Markdown.convert].
        rE)rBrEr@�clearr<�hasattrrvs  rHrEzMarkdown.resetsT��	
�������������2�2�	"�I��y�'�*����!�	"��rJc��|j�jd�|_	|j|j|_|S#t
$ry}t
|jj��}|j�d|j�dddj|�zdz�d�}|f|jddz|_
�d}~wwxYw)	z�
        Set the output format for the class instance.

        Arguments:
            format: Must be a known value in `Markdown.output_formats`.

        �145zInvalid Output Format: "z". Use one of �"z", "r1rN)�lower�rstripr7r�
serializer�KeyError�list�keys�sort�joinri)rFr\rr�
valid_formatsrss     rHrDzMarkdown.set_output_formats���$�\�\�^�2�2�5�9���		�"�1�1�$�2D�2D�E�D�O�����	� ��!4�!4�!9�!9�!;�<�M���� ��%�%�����]�3�3�c�9�;�G��Z�!�&�&���*�,�A�F���	�s�A�	C�A4C�Cc�z�t|t�r+|j�jd�|jvSy)z�
        Check if the given `tag` is a block level HTML tag.

        Returns `True` for any string listed in `Markdown.block_level_elements`. A `tag` which is
        not a string always returns `False`.

        �/F)rRrSrr�r;)rF�tags  rH�is_block_levelzMarkdown.is_block_level.s3���c�3���9�9�;�%�%�c�*�d�.G�.G�G�G�rJc��|j�sy	t|�}|j	d�|_|jD]"}|j|j
�|_�$|jj|j
�j�}|jD]}|j|�}|��|}�|j|�}|jri	|jd|jz�t!|j�zdz}|j#d|jz�}	|||	j�}|j(D]}
|
j|�}�|j�S#t$r}|xjdz
c_�d}~wwxYw#t$$rV}|j�j'd|jz�rd}nt%d	|j�z�|�Yd}~��d}~wwxYw)
a�
        Convert a Markdown string to a string in the specified output format.

        Arguments:
            source: Markdown formatted text as Unicode or ASCII string.

        Returns:
            A string in the specified output format.

        Markdown parsing takes place in five steps:

        1. A bunch of [`preprocessors`][markdown.preprocessors] munge the input text.
        2. A [`BlockParser`][markdown.blockparser.BlockParser] parses the high-level structural elements of the
           pre-processed text into an [`ElementTree`][xml.etree.ElementTree.ElementTree] object.
        3. A bunch of [`treeprocessors`][markdown.treeprocessors] are run against the
           [`ElementTree`][xml.etree.ElementTree.ElementTree] object. One such `treeprocessor`
           ([`markdown.treeprocessors.InlineProcessor`][]) runs [`inlinepatterns`][markdown.inlinepatterns]
           against the [`ElementTree`][xml.etree.ElementTree.ElementTree] object, parsing inline markup.
        4. Some [`postprocessors`][markdown.postprocessors] are run against the text after the
           [`ElementTree`][xml.etree.ElementTree.ElementTree] object has been serialized into text.
        5. The output is returned as a string.

        r3z/. -- Note: Markdown only accepts Unicode input!N�
z<%s>�z</%s>z<%s />z4Markdown failed to strip top-level tags. Document=%r)�striprS�UnicodeDecodeError�reasonre�linesrL�runrM�
parseDocument�getrootrOr�r>�index�doc_tag�len�rindex�
ValueError�endswithrP)rF�sourcerr�prep�root�
treeprocessor�newRoot�output�start�end�pps           rH�convertzMarkdown.convert;s���4�|�|�~��	���[�F��\�\�$�'��
��&�&�	.�D����$�*�*�-�D�J�	.��{�{�(�(����4�<�<�>��"�0�0�	�M�#�'�'��-�G��"���	�����&���!�!�
R�����T�\�\�)�+�-0����->�?�AB�C���m�m�G�d�l�l�$:�;����c�*�0�0�2���%�%�	$�B��V�V�F�^�F�	$��|�|�~���Q"�	�
�H�H�I�I�H���	��6�
R��<�<�>�*�*�8�d�l�l�+B�C��F�%�&9�;A�<�<�>�&J�K�PQ�R���
R�s1�E7�A(F�7	F�F�F�	G=�'AG8�8G=Nc���|xsd}|ret|t�rtj|d|��}ntj|�|�}|j�}|j
�ntjj�}|jd�}|j|�}|r~t|t�r<tj|d|d��}|j|�|j
�|Stj|�}||d��}|j|�|S|j|d�}tjjj|�|S)	a�
        Converts a Markdown file and returns the HTML as a Unicode string.

        Decodes the file using the provided encoding (defaults to `utf-8`),
        passes the file content to markdown, and outputs the HTML to either
        the provided stream or the file with provided name, using the same
        encoding as the source file. The
        [`xmlcharrefreplace`](https://docs.python.org/3/library/codecs.html#error-handlers)
        error handler is used when encoding the output.

        **Note:** This is the only place that decoding and encoding of Unicode
        takes place in Python-Markdown.  (All other code is Unicode-in /
        Unicode-out.)

        Arguments:
            input: File object or path. Reads from `stdin` if `None`.
            output: File object or path. Writes to `stdout` if `None`.
            encoding: Encoding of input and output files. Defaults to `utf-8`.

        zutf-8�r)�mode�encodingu�w�xmlcharrefreplace)r��errors)r�)rRrS�codecs�open�	getreader�read�close�sys�stdin�lstripr��write�	getwriter�encode�stdout�buffer)	rF�inputr�r��
input_file�textr�output_file�writers	         rH�convertFilezMarkdown.convertFile�s;��6�&�w����%��%�#�[�[��S�8�L�
�7�V�-�-�h�7��>�
��?�?�$�D������9�9�>�>�#�D��{�{�8�$���|�|�D�!����&�#�&�$�k�k�&�#�3;�1D�F���!�!�$�'��!�!�#��� �)�)�(�3��$�V�4G�H���!�!�$�'����;�;�x�)<�=�D��J�J���#�#�D�)��rJ)�returnr)r4zSequence[Extension | str]r6zMapping[str, dict[str, Any]]r�r)rmrSr6zMapping[str, Any]r�r)rwrr�r)r\rSr�r)r�rr��bool)r�rSr�rS)NNN)r��str | BinaryIO | Noner�r�r�z
str | Noner�r)rZrY�__qualname__�__doc__r�rrr�__annotations__rIr?rCrTrxrErDr�r�r�r`rJrHrr.s����<�G�!�!�E�N�A���
)�V�8"�-�"�.�"�
�	"�H3�j
�� �.�G�V(,�(,�#�	?�$�?�&�?��	?�

�?rJrc�:�tdi|��}|j|�S)a5
    Convert a markdown string to HTML and return HTML as a Unicode string.

    This is a shortcut function for [`Markdown`][markdown.Markdown] class to cover the most
    basic use case.  It initializes an instance of [`Markdown`][markdown.Markdown], loads the
    necessary extensions and runs the parser on the given text.

    Arguments:
        text: Markdown formatted text as Unicode or ASCII string.

    Keyword arguments:
        **kwargs: Any arguments accepted by the Markdown class.

    Returns:
        A string in the specified output format.

    r`)rr�)r�rG�mds   rHrr�s ��$
�	�F�	�B�
�:�:�d��rJc��tdi|��}|j|jdd�|jdd�|jdd��y)aE
    Read Markdown text from a file and write output to a file or a stream.

    This is a shortcut function which initializes an instance of [`Markdown`][markdown.Markdown],
    and calls the [`convertFile`][markdown.Markdown.convertFile] method rather than
    [`convert`][markdown.Markdown.convert].

    Keyword arguments:
        input (str | BinaryIO): A file name or readable object.
        output (str | BinaryIO): A file name or writable object.
        encoding (str): Encoding of input and output.
        **kwargs: Any arguments accepted by the `Markdown` class.

    r�Nr�r�r`)rr�r8)rGr�s  rHrr�sF��
�	�F�	�B��N�N�6�:�:�g�t�,��:�:�h��-��:�:�j�$�/�1rJ)r�rSrGrr�rS)rGr)(�
__future__rr�r��loggingrf�typingrrrrrr	r
r3rrLr
�blockprocessorsrrOr�inlinepatternsrrPrr4r�serializersrrr�xml.etree.ElementTreer�__all__�	getLoggerrVrrrr`rJrH�<module>r�su��(#�
�
���V�V�V��.�/�0�0�0�!�8�&��-�
6��
��	�	�:�	&��U�U�p��,1rJ

Zerion Mini Shell 1.0