a
    'ñ»jU  ã                   @  sØ   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	¡Zd dd	d
œdd„Zdddœdd„Zdddœdd„Zddœdd„Zddd
œdd„Zddœdd„ZedkrÔeejdd… ƒZe e¡ dS )!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 {}]zSequence[str] | NoneÚint)ÚargsÚreturnc                 C  s$   t | ƒ}|jrt|jƒ ntƒ  dS )Nr   )Ú
parse_argsÚ	filenamesÚconvertÚinteractive)r   Ú	namespace© r   ú;E:\soccer\ml_env\Lib\site-packages\markdown_it/cli/parse.pyÚmain   s
    r   zIterable[str]ÚNone)r   r	   c                 C  s   | D ]}t |ƒ qd S )N)Úconvert_file)r   Úfilenamer   r   r   r      s    r   Ústr)r   r	   c                 C  s†   zPt | dddd��,}tƒ  | ¡ ¡}t|dd� W d  ƒ n1 sD0    Y  W n0 ty€   tj d| › d	�¡ t 	d
¡ Y n0 dS )z>
    Parse a Markdown file and dump the output to stdout.
    ÚrÚutf8Úignore)ÚencodingÚerrorsÚ ©ÚendNzCannot open file "z".
é   )
Úopenr   ÚrenderÚreadÚprintÚOSErrorÚsysÚstderrÚwriteÚexit)r   ZfinÚrenderedr   r   r   r   !   s    .r   )r	   c               
   C  s�   t ƒ  g } d}z&|rdnd\}}|  t|ƒd ¡ W q tyl   tdtƒ  d | ¡¡ dd� d}g } Y q tyˆ   tdƒ Y qŒY q0 qdS )	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Úpromptr   r   r   r   .   s    r   zargparse.Namespacec                 C  sF   t jddt› d�t jd�}|jdddtd� |jd	d
dd� | | ¡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ÚepilogZformatter_classz-vz	--versionÚversion)Úactionr5   r   Ú*z,specify an optional list of files to convert)ÚnargsÚhelp)ÚargparseÚArgumentParserr   ZRawDescriptionHelpFormatterÚadd_argumentÚversion_strr
   )r   Úparserr   r   r   r
   C   s    üèÿr
   c                   C  s   t d t¡ƒ t dƒ d S )Nz{} (interactive)z1Type Ctrl-D to complete input, or Ctrl-C to exit.)r"   Úformatr=   r   r   r   r   r*   f   s    r*   Ú__main__r   )N)Ú__doc__Ú
__future__r   r:   Úcollections.abcr   r   r$   Zmarkdown_itr   Zmarkdown_it.mainr   r?   r=   r   r   r   r   r
   r*   Ú__name__ÚargvÚ	exit_coder'   r   r   r   r   Ú<module>   s    
	#