
    \j"                        d Z ddlmZ ddlZddlmZmZ ddlZddlm	Z	 ddl
mZ de	 dZddd	Zdd
ZddZddZddZddZddZedk(  r( eej*                  dd       Z ej.                  e       yy)zo
CLI interface to markdown-it-py

Parse one or more markdown files, convert each to HTML, and print to stdout.
    )annotationsN)IterableSequence)__version__)
MarkdownItzmarkdown-it-py [version ]c                    t        |       }|j                  rt        |j                         y|j                  rt	                yt                y)Nr   )
parse_args	filenamesconvertstdinconvert_stdininteractive)args	namespaces     ?/root/env/lib/python3.12/site-packages/markdown_it/cli/parse.pymainr      sE    4 I	##$
 	 
  	    c                (    | D ]  }t        |        y N)convert_file)r   filenames     r   r   r      s     Xr   c                    	 t               j                  t        j                  j	                               } t        | d       y# t        $ r7 t        j                  j                  d       t        j                  d       Y yw xY w)>
    Parse a Markdown file and dump the output to stdout.
     endz/Cannot parse Markdown from the standard input.
   N)
r   rendersysr   readprintOSErrorstderrwriteexit)rendereds    r   r   r   $   s[    <&&syy~~'78hB 

KLs   AA =BBc                B   	 t        | dd      5 }t               j                  |j                               }t	        |d       ddd       y# 1 sw Y   yxY w# t
        $ r; t        j                  j                  d|  d       t        j                  d	       Y yw xY w)
r   utf8ignore)encodingerrorsr   r   NzCannot open file "z".
r   )
openr   r   r!   r"   r#   r    r$   r%   r&   )r   finr'   s      r   r   r   0   s    (VH= 	$!|**388:6H(#	$ 	$ 	$  

-hZt<=s/   A 5AA AA A ABBc            	     ,   t                g } d}	 	 |rdnd\  }}| j                  t        |      dz          (# t        $ r= t	        dt               j                  dj                  |             z   d       d}g } Y Ft        $ r t	        d       Y yw xY w)	zT
    Parse user input, dump to stdout, rinse and repeat.
    Python REPL style.
    F)z... T)z>>> T
r   r   z	
Exiting.N)	print_headingappendinputEOFErrorr"   r   r   joinKeyboardInterrupt)contentsmoreprompts      r   r   r   =   s    
 OHD
		-1>~LFDOOE&MD01   	$,,TYYx-@AArJDH  	,	s   &8 AB=BBc                   t        j                  ddt         dt         j                        }|j	                  dddt
               |j	                  d	d
d       |j	                  ddd       |j                  |       S )zParse input CLI arguments.zKParse one or more markdown files, convert each to HTML, and print to stdoutz9
Interactive:

  $ markdown-it
  markdown-it-py [version a  ] (interactive)
  Type Ctrl-D to complete input, or Ctrl-C to exit.
  >>> # Example
  ... > markdown *input*
  ...
  <h1>Example</h1>
  <blockquote>
  <p>markdown <em>input</em></p>
  </blockquote>

Batch:

  $ markdown-it README.md README.footer.md > index.html
)descriptionepilogformatter_classz-vz	--versionversion)actionr>   z--stdin
store_truez!read Markdown from standard input)r?   helpr   *z,specify an optional list of files to convert)nargsrA   )argparseArgumentParserr   RawDescriptionHelpFormatteradd_argumentversion_strr
   )r   parsers     r   r
   r
   R   s    $$4 '- (	& !<<1F4 k)[Q
,-P   3%S   T""r   c                 >    t        t         d       t        d       y )Nz (interactive)z1Type Ctrl-D to complete input, or Ctrl-C to exit.)r"   rH    r   r   r1   r1   x   s    	[M
()	
=>r   __main__r   r   )r   Sequence[str] | Nonereturnint)r   zIterable[str]rN   None)rN   rP   )r   strrN   rP   )r   rM   rN   zargparse.Namespace)__doc__
__future__r   rD   collections.abcr   r   r    markdown_itr   markdown_it.mainr   rH   r   r   r   r   r   r
   r1   __name__argv	exit_coder&   rK   r   r   <module>rZ      s    #  . 
 # '(Q7
	
*##L?
 zSXXab\"ICHHY r   