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   [/var/www/html/fyndo/pharma/fyndo/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&   





&