o
    Ù­j"  ã                   @  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	› d�Zd#d$dd„Zd%dd„Zd&dd„Zd'dd„Zd&dd„Zd(dd„Zd&dd „Zed!krbeejd"d… ƒZe e¡ dS 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 ú]ÚargsúSequence[str] | NoneÚreturnÚintc                 C  s6   t | ƒ}|jrt|jƒ dS |jrtƒ  dS tƒ  dS )Nr   )Ú
parse_argsÚ	filenamesÚconvertÚstdinÚconvert_stdinÚinteractive)r   Ú	namespace© r   úR/var/www/html/CropPilot/venv/lib/python3.10/site-packages/markdown_it/cli/parse.pyÚmain   s   
üÿr   r   úIterable[str]ÚNonec                 C  s   | D ]}t |ƒ qd S ©N)Úconvert_file)r   Úfilenamer   r   r   r      s   
ÿr   c                  C  sP   zt ƒ  tj ¡ ¡} t| dd� W dS  ty'   tj d¡ t 	d¡ Y dS 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)Úrenderedr   r   r   r   $   s   þr   r   Ústrc                 C  sˆ   z*t | ddd��}tƒ  | ¡ ¡}t|dd� W d  ƒ W dS 1 s#w   Y  W dS  tyC   tj d| › d�¡ t 	d	¡ Y dS w )
r   Úutf8Úignore)ÚencodingÚerrorsr   r   NzCannot open file "z".
r   )
Úopenr   r    r"   r#   r$   r!   r%   r&   r'   )r   Úfinr(   r   r   r   r   0   s   &þþr   c               
   C  sŒ   t ƒ  g } d}	 z|rdnd\}}|  t|ƒd ¡ W n) ty7   tdtƒ  d | ¡¡ dd� d}g } Y n tyD   tdƒ Y d	S w q)
zT
    Parse user input, dump to stdout, rinse and repeat.
    Python REPL style.
    FT)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   úargparse.Namespacec                 C  sV   t jddt› d�t jd�}|jdddtd� |jd	d
d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Ú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   Úparserr   r   r   r   R   s   üèÿÿ
r   c                   C  s   t t› d�ƒ t dƒ d S )Nz (interactive)z1Type Ctrl-D to complete input, or Ctrl-C to exit.)r#   rH   r   r   r   r   r1   x   s   r1   Ú__main__r   r   )r   r	   r
   r   )r   r   r
   r   )r
   r   )r   r)   r
   r   )r   r	   r
   r:   )Ú__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'   r   r   r   r   Ú<module>   s&   





&þ