
    ̆hPS                    4   S SK Jr  S SKrS SKrS SKrS SKrS SKJrJrJ	r	J
r
JrJrJr  SSKJr  SSKJr  SSKJr  SSKJr  SS	KJr  SS
KJr  SSKJr  SSKJrJr  SSKJr  \(       a  S SK J!r!  / SQr"\RF                  " S5      r$ " S S5      r% SS jr&SS jr'g)    )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                      \ rS rSr% SrSr\\S.rS\	S'    S r
SS jr      SS	 jrSS
 jrSS jrSS jrSS jrSS jrSS jr   S       SS jjrSrg)r   .   a  
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                   UR                  SS5      U l        / SQU l         [        R                  " 5       U l        / U l        SU l        SU l        U R                  5         0 U l
        [        R                  " 5       U l        U R                  UR                  S/ 5      UR                  S0 5      S9  U R                  UR                  S	S
5      5        U R!                  5         g)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)r5   configsoutput_formatr   N)getr"   ESCAPED_CHARSr   copyblock_level_elementsregisteredExtensionsdocTypestripTopLevelTagsbuild_parser
referencesr   	HtmlStash	htmlStashregisterExtensionsset_output_formatreset)selfkwargss     E/opt/services/DDDS/venv/lib/python3.13/site-packages/markdown/core.py__init__Markdown.__init__X   s    *  &zz,:)
 	M/C/H/H/J!57!'+68)-)96::lB+G(.

3F(K 	  	Mvzz/7CD

    c                    [        U 5      U l        [        U 5      U l        [	        U 5      U l        [        U 5      U l        [        U 5      U l	        U $ )a  
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)rG   s    rI   r@   Markdown.build_parser   sI    * 16(.248248248rL   c           	     *   U GH  n[        U[        5      (       a!  U R                  X2R                  U0 5      5      n[        U[        5      (       aY  UR                  U 5        [        R                  SUR                  R                  < SUR                  R                  < S35        M  Uc  M  [        SR                  UR                  R                  UR                  R                  [        R                  [        R                  5      5      e   U $ )aB  
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.

zSuccessfully loaded extension "r2   z".z*Extension "{}.{}" must be of type: "{}.{}")
isinstancestrbuild_extensionr9   r   extendMarkdownloggerdebug	__class__
__module____name__	TypeErrorformat)rG   r5   r7   exts       rI   rD   Markdown.registerExtensions   s    $ C#s##**3C0DE#y))""4(}}//1G1GI @GG00#--2H2H!,,i.@.@    rL   c                   [        U5      n[        R                  " 5        Vs/ s H  o3R                  U:X  d  M  UPM     nnU(       a  US   R	                  5       nU" S
0 UD6$ SU;   a  UR                  SS5      OUS4u  p [        R                  " U5      n[        R                  SU-  5        U(       a  [        Xv5      " S
0 UD6$  UR                  " S
0 UD6$ s  snf ! [         a#  nSU-  n	U	4UR                  SS -   Ul        e SnAff = f! [         a7  nUR                  S   n	SU< S	U	< 3n	U	4UR                  SS -   Ul        e SnAff = f)ac  
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   :r   r4   z,Successfully imported extension module "%s".zFailed loading extension "%s".NzFailed to initiate extension 'z':  )dictr   get_installed_extensionsnameloadsplit	importlibimport_modulerY   rZ   ImportErrorargsgetattrmakeExtensionAttributeError)
rG   ext_namer7   epentry_pointsr`   
class_namemoduleemessages
             rI   rW   Markdown.build_extension   sU   & w-%)%B%B%D\%DrS[H[%D\q/&&(C>>! :=x~~c15xY[n	,,X6FLL>I 6.999++6g661 ]  	6AGZ!&&*,AF	 " &&)(0';!affQRj0s:   CC.C! 
D !
D+D		D
E2EEc                <    U R                   R                  U5        U $ )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rG   	extensions     rI   registerExtensionMarkdown.registerExtension   s     	!!((3rL   c                    U R                   R                  5         U R                  R                  5         U R                   H&  n[        US5      (       d  M  UR                  5         M(     U $ )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].
rF   )rC   rF   rA   clearr=   hasattrr{   s     rI   rF   Markdown.reset  sR     	22Iy'**! 3 rL   c                   UR                  5       R                  S5      U l         U R                  U R                     U l        U $ ! [
         a{  n[        U R                  R                  5       5      nUR                  5         SU R                  < SSSR                  U5      -   S-   < S3nU4UR                  SS -   Ul
        e SnAff = f)	z|
Set the output format for the class instance.

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

145zInvalid Output Format: "z". Use one of "z", "r2   r   N)lowerrstripr8   r    
serializerKeyErrorlistkeyssortjoinrm   )rG   r_   rv   valid_formatsrw   s        rI   rE   Markdown.set_output_format  s     $\\^2259		"11$2D2DEDO   	 !4!4!9!9!;<M %%]33c9;G Z!&&*,AF	s   A 
CA6CCc                    [        U[        5      (       a,  UR                  5       R                  S5      U R                  ;   $ g)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)rU   rV   r   r   r<   )rG   tags     rI   is_block_levelMarkdown.is_block_level.  s6     c399;%%c*d.G.GGGrL   c                .   UR                  5       (       d  g [        U5      nUR	                  S5      U l        U R                   H#  nUR                  U R
                  5      U l        M%     U R                  R                  U R
                  5      R                  5       nU R                   H  nUR                  U5      nUc  M  UnM     U R                  U5      nU R                  (       ah   UR                  SU R                  -  5      [!        U R                  5      -   S-   nUR#                  SU R                  -  5      n	XxU	 R                  5       nU R(                   H  n
U
R                  U5      nM     UR                  5       $ ! [         a  nU=R                  S-  sl        e SnAff = f! [$         aZ  nUR                  5       R'                  SU R                  -  5      (       a  Sn SnAN[%        S	UR                  5       -  5      UeSnAff = f)
aL  
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.

r4   z/. -- Note: Markdown only accepts Unicode input!N
z<%s>   z</%s>z<%s />z4Markdown failed to strip top-level tags. Document=%r)striprV   UnicodeDecodeErrorreasonri   linesrN   runrO   parseDocumentgetrootrQ   r   r?   indexdoc_taglenrindex
ValueErrorendswithrR   )rG   sourcerv   preproottreeprocessornewRootoutputstartendpps              rI   convertMarkdown.convert;  s   4 ||~~	[F \\$'
&&D$**-DJ ' {{((4<<> "00M#''-G" 1 &!!RT\\)+-0->?ABCmmGdll$:;c*002 %%BVVF^F & ||~Q " 	HHIIH	6  R<<>**8dll+BCCF % &9;A<<>&J KPQRRs6   F -A'F0 
F-F((F-0
H:3H2HHNc                   U=(       d    SnU(       a^  [        U[        5      (       a  [        USUS9nO[        R                  " U5      " U5      nUR                  5       nUR                  5         O[        R                  R                  5       nUR                  S5      nU R                  U5      nU(       a  [        U[        5      (       a:  [        R                  " USUSS9nUR                  U5        UR                  5         U $ [        R                  " U5      nU" USS9nUR                  U5         U $ UR                  US5      n[        R                  R                  R                  U5        U $ )	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`.

zutf-8r)modeencodingu   ﻿wxmlcharrefreplace)r   errors)r   )rU   rV   opencodecs	getreaderreadclosesysstdinlstripr   write	getwriterencodestdoutbuffer)	rG   inputr   r   
input_filetextr   output_filewriters	            rI   convertFileMarkdown.convertFile  s;   6 &w %%%!%cHE
#--h7>
??$D99>>#D{{8$ ||D! &#&&$kk&#3;1DF !!$'!!#   ))(3$V4GH!!$'  ;;x)<=DJJ##D)rL   )r:   r<   r>   rC   rP   r   r8   rO   rR   rN   rA   r=   r   r?   r"   rQ   )returnr   )r5   zSequence[Extension | str]r7   zMapping[str, dict[str, Any]]r   r   )rq   rV   r7   zMapping[str, Any]r   r   )r|   r   r   r   )r_   rV   r   r   )r   r   r   bool)r   rV   r   rV   )NNN)r   str | BinaryIO | Noner   r   r   z
str | Noner   r   )r]   r\   __qualname____firstlineno____doc__r   r   r   r    __annotations__rJ   r@   rD   rW   r}   rF   rE   r   r   r   __static_attributes__rd   rL   rI   r   r   .   s    < G !!ENA 
)V8"-" ." 
	"H3j .GV (,(,#	?$? &? 	?
 
? ?rL   r   c                :    [        S0 UD6nUR                  U 5      $ )a	  
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.

rd   )r   r   )r   rH   mds      rI   r   r     s     $ 
	F	B::drL   c                     [        S0 U D6nUR                  U R                  SS5      U R                  SS5      U R                  SS5      5        g)a  
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   rd   )r   r   r9   )rH   r   s     rI   r   r     sF     
	F	BNN6::gt,::h-::j$/1rL   )r   rV   rH   r   r   rV   )rH   r   )(
__future__r   r   r   loggingrj   typingr   r   r   r   r   r	   r
   r4   r   rN   r   blockprocessorsr   rQ   r   inlinepatternsr   rR   r   r5   r   serializersr   r   r   xml.etree.ElementTreer   __all__	getLoggerrY   r   r   r   rd   rL   rI   <module>r      ss   ( #  
   V V V  . / 0 0 0 ! 8 &-
6 
		:	&U Up,1rL   