File: //opt/alt/python37/lib/python3.7/site-packages/markdown_it/cli/__pycache__/parse.cpython-37.pyc
B
��fU � @ s� d Z ddlmZ ddlZddlmZmZ ddlZddlm Z ddl
mZ d�e �Z
d dd d
�dd�Zd
dd�dd�Zddd�dd�Zdd�dd�Zddd
�dd�Zdd�dd�Zedkr�eejdd� �Ze�e� dS )!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__)�
MarkdownItzmarkdown-it-py [version {}]zSequence[str] | None�int)�args�returnc C s$ t | �}|jrt|j� nt� dS )Nr )�
parse_args� filenames�convert�interactive)r � namespace� r �F/opt/alt/python37/lib/python3.7/site-packages/markdown_it/cli/parse.py�main s
r z
Iterable[str]�None)r r c C s x| D ]}t |� qW d S )N)�convert_file)r �filenamer r r r s
r �str)r r c C st y<t | dddd��"}t� �|�� �}t|dd� W dQ R X W n2 tk
rn tj�d| � d �� t� d
� Y nX dS )z>
Parse a Markdown file and dump the output to stdout.
�r�utf8�ignore)�encoding�errors� )�endNzCannot open file "z".
� )
�openr �render�read�print�OSError�sys�stderr�write�exit)r Zfin�renderedr r r r ! s r )r c
C s� t � g } d}x�y&|rdnd\}}| �t|�d � W q tk
rp tdt� �d�| �� dd� d}g } Y q tk
r� td� P Y qX qW dS ) 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)�contentsZmore�promptr r r r
. s r
zargparse.Namespacec C sF t jddt� d�t jd�}|jdddtd� |jd d
dd� |�| �S )
zParse 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)�actionr4 r �*z,specify an optional list of files to convert)�nargs�help)�argparse�ArgumentParserr �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 r9 �collections.abcr r r# Zmarkdown_itr Zmarkdown_it.mainr r? r= r r r r
r
r) �__name__�argvZ exit_coder&