o
    ç&•a«  ã                   @   sÎ   d Z ddlZddlZddlZddlZddlZzddlmZ W n! e	y?   zddlm
Z W n e	y<   ddlm
Z Y nw Y nw ddlZddlmZmZmZ e d¡Zddd„Zd	d
„ Zedkreeƒ  dS dS )aÚ  
Python Markdown

A Python implementation of John Gruber's Markdown.

Documentation: https://python-markdown.github.io/
GitHub: https://github.com/Python-Markdown/markdown/
PyPI: https://pypi.org/project/Markdown/

Started by Manfred Stienstra (http://www.dwerg.net/).
Maintained for a few years by Yuri Takhteyev (http://www.freewisdom.org).
Currently maintained by Waylan Limberg (https://github.com/waylan),
Dmitry Shachnev (https://github.com/mitya57) and Isaac Muse (https://github.com/facelessuser).

Copyright 2007-2018 The Python Markdown Project (v. 1.7 and later)
Copyright 2004, 2005, 2006 Yuri Takhteyev (v. 0.2-1.6b)
Copyright 2004 Manfred Stienstra (the original version)

License: BSD (see LICENSE.md for details).
é    N)Úunsafe_load)Úload)ÚDEBUGÚWARNINGÚCRITICALÚMARKDOWNc                 C   sÌ  d}d}dt j }tj|||d�}|jddddd	d
d� |jddddd� |jddddddd� |jddddddd� |jdd d!d"d#d$d%� |jd&d'd(dd)d*d� |jd+d,td-td. d/d0d1� |jd2d3d-td/d4d5� |jd6d-td/d7d5� | | |¡\}} t	| ƒd8kr…d}n| d8 }|j
s�g |_
i }|jrÒtj|jd9|jd:��,}	zt|	ƒ}W n tyÂ }
 zd;|j }|f|
jd<d…  |
_‚ d}
~
ww W d  ƒ n1 sÍw   Y  ||j|j
||j|j|jd=œ}||jfS )>zE
    Define and parse `optparse` options for command-line usage.
    zN%prog [options] [INPUTFILE]
       (STDIN is assumed if no INPUTFILE is given)zUA Python implementation of John Gruber's Markdown. https://Python-Markdown.github.io/z	%%prog %s)ÚusageÚdescriptionÚversionz-fz--fileÚfilenameNz0Write output to OUTPUT_FILE. Defaults to STDOUT.ÚOUTPUT_FILE)ÚdestÚdefaultÚhelpÚmetavarz-ez
--encodingÚencodingz$Encoding for input and output files.)r   r   z-oz--output_formatÚoutput_formatÚxhtmlÚOUTPUT_FORMATz.Use output format 'xhtml' (default) or 'html'.)r   r   r   r   z-nz--no_lazy_olÚlazy_olÚstore_falseTz.Observe number of first item of ordered lists.)r   Úactionr   r   z-xz--extensionÚappendÚ
extensionszLoad extension EXTENSION.Ú	EXTENSION)r   r   r   r   z-cz--extension_configsÚ
configfileaq  Read extension configurations from CONFIG_FILE. CONFIG_FILE must be of JSON or YAML format. YAML format requires that a python YAML library be installed. The parsed JSON or YAML must result in a python dictionary which would be accepted by the 'extension_configs' keyword on the markdown.Markdown class. The extensions must also be loaded with the `--extension` option.ÚCONFIG_FILEz-qz--quietÚstore_consté
   ÚverbosezSuppress all warnings.)r   r   Úconstr   r   z-vz	--verbosezPrint all warnings.)r   r    r   r   z--noisyzPrint debug messages.r   Úr)Úmoder   z(Failed parsing extension config file: %sé   )ÚinputÚoutputr   Úextension_configsr   r   r   )ÚmarkdownÚ__version__ÚoptparseÚOptionParserÚ
add_optionr   r   r   Ú
parse_argsÚlenr   r   ÚcodecsÚopenr   Ú	yaml_loadÚ	ExceptionÚargsr   r   r   r   )r2   Úvaluesr   ÚdescÚverÚparserÚoptionsÚ
input_filer&   ÚfpÚeÚmessageÚopts© r=   ú3/usr/lib/python3/dist-packages/markdown/__main__.pyÚparse_options.   s�   
þ
ÿ
þ
þÿö

þþþ
ÿÿ€üÿüù

r?   c                  C   sx   t ƒ \} }| st d¡ t |¡ t ¡ }t |¡ |tkr2t	 
d¡ t d¡ t d¡}| |¡ tjdi | ¤Ž dS )z#Run Markdown from the command line.é   r   Tzpy.warningsNr=   )r?   ÚsysÚexitÚloggerÚsetLevelÚloggingÚStreamHandlerÚ
addHandlerr   ÚwarningsÚfilterwarningsÚcaptureWarningsÚ	getLoggerr'   ÚmarkdownFromFile)r7   Úlogging_levelÚconsole_handlerÚwarn_loggerr=   r=   r>   Úrun   s   







rP   Ú__main__)NN)Ú__doc__rA   r)   r.   rH   r'   Úyamlr   r0   ÚImportErrorr   ÚjsonrE   r   r   r   rK   rC   r?   rP   Ú__name__r=   r=   r=   r>   Ú<module>   s0    þ€ü

Q
ý