Why Gemfury? Push, build, and install  RubyGems npm packages Python packages Maven artifacts PHP packages Go Modules Debian packages RPM packages NuGet packages

Repository URL to install this package:

Details    
Markdown / __init__.pyc
Size: Mime:
ó
Âö™Wc@@sHdZddlmZddlmZddlmZmZddlZddlZddl	Z	ddl
Z
ddlZddlm
Z
ddlmZdd	lmZdd
lmZddlmZddlmZdd
lmZddlmZmZdddgZe	jdƒZde fd„ƒYZ!d„Z"d„Z#dS(uØ
Python Markdown
===============

Python Markdown converts Markdown to HTML and can be used as a library or
called from the command line.

## Basic usage as a module:

    import markdown
    html = markdown.markdown(your_text_string)

See <https://pythonhosted.org/Markdown/> for more
information and instructions on how to extend the functionality of
Python Markdown.  Read that before you try modifying this file.

## Authors and License

Started by [Manfred Stienstra](http://www.dwerg.net/).  Continued and
maintained  by [Yuri Takhteyev](http://www.freewisdom.org), [Waylan
Limberg](http://achinghead.com/) and [Artem Yunusov](http://blog.splyer.com).

Contact: markdown@freewisdom.org

Copyright 2007-2013 The Python Markdown Project (v. 1.7 and later)
Copyright 200? Django Software Foundation (OrderedDict implementation)
Copyright 2004, 2005, 2006 Yuri Takhteyev (v. 0.2-1.6b)
Copyright 2004 Manfred Stienstra (the original version)

License: BSD (see LICENSE for details).
i(tabsolute_import(tunicode_literalsi(tversiontversion_infoN(tutil(tbuild_preprocessors(tbuild_block_parser(tbuild_treeprocessors(tbuild_inlinepatterns(tbuild_postprocessors(t	Extension(tto_html_stringtto_xhtml_stringuMarkdownumarkdownumarkdownFromFileuMARKDOWNtMarkdowncB@sýeZdZdZidd6dd6ed6ed6ed6Zied	6ed
6ed6ed6ed
6ed6ZddddddddddddddddgZ	d„Z
d „Zd!„Zd"„Z
d#„Zd$„Zd%„Zd&„Zd(d(d(d'„ZRS()uConvert Markdown to HTML.udivu[HTML_REMOVED]uhtml_replacement_textiu
tab_lengthuenable_attributesusmart_emphasisulazy_oluhtmluhtml4uhtml5uxhtmluxhtml1uxhtml5u\u`u*u_u{u}u[u]u(u)u>u#u+u-u.u!cO@sËddddg}xUt|ƒD]G\}}|||krL||||<n|dt|ƒkrPqqWt|ƒr‰tjdtƒnx9|jjƒD](\}}t|||j||ƒƒq™W|jdt	ƒ|_
|j
rûd|krût	|_nd|krtjdtƒnd	|kr9tjd
tƒng|_d|_
t|_|jƒi|_tjƒ|_|jd|jdgƒd
|jdiƒƒ|j|jddƒƒ|jƒdS(u
        Creates a new Markdown instance.

        Keyword arguments:

        * extensions: A list of extensions.
           If they are of type string, the module mdx_name.py will be loaded.
           If they are a subclass of markdown.Extension, they will be used
           as-is.
        * extension_configs: Configuration settings for extensions.
        * output_format: Format of output. Supported formats are:
            * "xhtml1": Outputs XHTML 1.x. Default.
            * "xhtml5": Outputs XHTML style tags of HTML 5
            * "xhtml": Outputs latest supported version of XHTML
              (currently XHTML 1.1).
            * "html4": Outputs HTML 4
            * "html5": Outputs HTML style tags of HTML 5
            * "html": Outputs latest supported version of HTML
              (currently HTML 4).
            Note that it is suggested that the more specific formats ("xhtml1"
            and "html4") be used as "xhtml" or "html" may change in the future
            if it makes sense at that time.
        * safe_mode: Deprecated! Disallow raw html. One of "remove", "replace"
          or "escape".
        * html_replacement_text: Deprecated! Text used when safe_mode is set
          to "replace".
        * tab_length: Length of tabs in the source. Default: 4
        * enable_attributes: Enable the conversion of attributes. Default: True
        * smart_emphasis: Treat `_connected_words_` intelligently Default: True
        * lazy_ol: Ignore number of first item of ordered lists. Default: True

        u
extensionsuextension_configsu	safe_modeu
output_formatiuLPositional arguments are deprecated in Markdown. Use keyword arguments only.uenable_attributesuÄ"safe_mode" is deprecated in Python-Markdown. Use an HTML sanitizer (like Bleach http://bleach.readthedocs.org/) if you are parsing untrusted markdown text. See the 2.6 release notes for more infouhtml_replacement_textuIThe "html_replacement_text" keyword is deprecated along with "safe_mode".ut
extensionstconfigsuxhtml1N(t	enumeratetlentwarningstwarntDeprecationWarningtoption_defaultstitemstsetattrtgettFalsetsafeModetenable_attributestregisteredExtensionstdocTypetTruetstripTopLevelTagstbuild_parsert
referencesRt	HtmlStasht	htmlStashtregisterExtensionstset_output_formattreset(tselftargstkwargstpostctargtoptiontdefault((s/build/lib.linux-x86_64-2.7/markdown/__init__.pyt__init__Qs<#	
 	
	
			
	cC@sOt|ƒ|_t|ƒ|_t|ƒ|_t|ƒ|_t|ƒ|_	|S(u* Build the parser from the various parts. (
Rt
preprocessorsRtparserRtinlinePatternsRttreeprocessorsR	tpostprocessors(R'((s/build/lib.linux-x86_64-2.7/markdown/__init__.pyR £scC@sÁxº|D]²}t|tjƒr@|j||j|iƒƒ}nt|tƒrˆ|j|tƒƒtj	d|j
j|j
jfƒq|dk	rtd|j
j|j
jfƒ‚qqW|S(u*
        Register extensions with this instance of Markdown.

        Keyword arguments:

        * extensions: A list of extensions, which can either
           be strings or objects.  See the docstring on Markdown.
        * configs: A dictionary mapping module names to config options.

        u&Successfully loaded extension "%s.%s".u7Extension "%s.%s" must be of type: "markdown.Extension"N(t
isinstanceRtstring_typetbuild_extensionRR
textendMarkdowntglobalstloggertdebugt	__class__t
__module__t__name__tNonet	TypeError(R'RRtext((s/build/lib.linux-x86_64-2.7/markdown/__init__.pyR$¬s
!#cC@sÕt|ƒ}|jdƒ}|dkr¸||dd!}|| }g|jdƒD]}|jdƒ^qR}|jg|D]$\}}|jƒ|jƒf^qzƒtjdtƒnd|krÖ|jddƒn	|d	f\}}y^tj	|ƒ}	t
jd
|ƒd|krEt|	dƒp8|o8t|	|ƒrEt
‚nWnt
k
rYdjd
|gƒ}
y>tj	|
ƒ}	t
jd
|
ƒtjd|
|ftƒWqZt
k
rUdjd|gƒ}y>tj	|ƒ}	t
jd
|ƒtjd||ftƒWqVt
k
rQ}d|||
|f}
|
f|jd|_‚qVXqZXnX|rst|	|ƒ|Sy|	j|SWnJtk
rÐ}|jd}
d||
f}
|
f|jd|_‚nXdS(uÆBuild extension by name, then return the module.

        The extension name may contain arguments as part of the string in the
        following format: "extname(key1=value1,key2=value2)"

        u(iiiÿÿÿÿu,u=u1Setting configs in the Named Extension string is deprecated. It is recommended that you pass an instance of the extension class to Markdown or use the "extension_configs" keyword. The current behavior will raise an error in version 2.7. See the Release Notes for Python-Markdown version 2.6 for more info.u:uu+Successfuly imported extension module "%s".u.u
makeExtensionumarkdown.extensionsuUsing short names for Markdown's builtin extensions is deprecated. Use the full path to the extension with Python's dot notation (eg: "%s" instead of "%s"). The current behavior will raise an error in version 2.7. See the Release Notes for Python-Markdown version 2.6 for more info.u_umdxu$Markdown's behavior of prepending "mdx_" to an extension name is deprecated. Use the full path to the extension with Python's dot notation (eg: "%s" instead of "%s"). The current behavior will raise an error in version 2.7. See the Release Notes for Python-Markdown version 2.6 for more info.u5Failed loading extension '%s' from '%s', '%s' or '%s'u%Failed to initiate extension '%s': %sN(tdicttfindtsplittupdatetstripRRRt	importlibt
import_moduleR:R;thasattrtImportErrortjoinR(tgetattrt
makeExtensiontAttributeError(R'text_nameRR*text_argstxtpairstyt
class_nametmoduletmodule_nametmodule_name_old_styletetmessage((s/build/lib.linux-x86_64-2.7/markdown/__init__.pyR7Çsj
+8	
0

	

	
	


cC@s|jj|ƒ|S(u# This gets called by the extension (Rtappend(R't	extension((s/build/lib.linux-x86_64-2.7/markdown/__init__.pytregisterExtension+scC@sN|jjƒ|jjƒx-|jD]"}t|dƒr$|jƒq$q$W|S(uR
        Resets all state variables so that we can start with a new text.
        ureset(R#R&R!tclearRRI(R'R[((s/build/lib.linux-x86_64-2.7/markdown/__init__.pyR&0s

cC@s|jƒ|_y|j|j|_Wnptk
r˜}t|jjƒƒ}|jƒd|jddj|ƒdf}|f|j	d|_	‚nX|S(u/ Set the output format for the class instance. u+Invalid Output Format: "%s". Use one of %s.u"u", "i(
tlowert
output_formattoutput_formatst
serializertKeyErrortlisttkeystsortRKR((R'tformatRXt
valid_formatsRY((s/build/lib.linux-x86_64-2.7/markdown/__init__.pyR%=s
cC@sÖ|jƒsdSytj|ƒ}Wn%tk
rJ}|jd7_‚nX|jdƒ|_x,|jjƒD]}|j	|jƒ|_qmW|j
j|jƒjƒ}x;|j
jƒD]*}|j	|ƒ}|d	k	r·|}q·q·W|j|ƒ}|jr£yT|jd|jƒt|jƒd}|jd|jƒ}	|||	!jƒ}Wq£tk
rŸ|jƒjd|jƒr†d}q td|jƒƒ‚q£Xnx&|jjƒD]}
|
j	|ƒ}q³W|jƒS(
uä
        Convert markdown to serialized XHTML or HTML.

        Keyword arguments:

        * source: Source text as a Unicode string.

        Markdown processing takes place in five steps:

        1. A bunch of "preprocessors" munge the input text.
        2. BlockParser() parses the high-level structural elements of the
           pre-processed text into an ElementTree.
        3. A bunch of "treeprocessors" are run against the ElementTree. One
           such treeprocessor runs InlinePatterns against the ElementTree,
           detecting inline markup.
        4. Some post-processors are run against the text after the ElementTree
           has been serialized into text.
        5. The output is written to a string.

        uu/. -- Note: Markdown only accepts unicode input!u
u<%s>iu</%s>u<%s />u4Markdown failed to strip top-level tags. Document=%rN(RFRt	text_typetUnicodeDecodeErrortreasonRDtlinesR0tvaluestrunR1t
parseDocumenttgetrootR3R?RaRtindextdoc_tagRtrindext
ValueErrortendswithR4(R'tsourceRXtpreptroott
treeprocessortnewRoottoutputtstarttendtpp((s/build/lib.linux-x86_64-2.7/markdown/__init__.pytconvertLs:
	'
	c	C@s“|p	d}|rpt|tjƒrBtj|ddd|ƒ}ntj|ƒ|ƒ}|jƒ}|jƒn3tj	jƒ}t|tj
ƒs£|j|ƒ}n|jdƒ}|j
|ƒ}|rBt|tjƒrtj|dd|ddƒ}|j|ƒ|jƒqtj|ƒ}||ddƒ}|j|ƒnM|j|dƒ}ytjjj|ƒWn!tk
rŽtjj|ƒnX|S(	u?Converts a Markdown file and returns the HTML as a Unicode string.

        Decodes the file using the provided encoding (defaults to utf-8),
        passes the file content to markdown, and outputs the html to either
        the provided stream or the file with provided name, using the same
        encoding as the source file. The 'xmlcharrefreplace' error handler is
        used when encoding the output.

        **Note:** This is the only place that decoding and encoding of Unicode
        takes place in Python-Markdown.  (All other code is Unicode-in /
        Unicode-out.)

        Keyword arguments:

        * input: File object or path. Reads from stdin if `None`.
        * output: File object or path. Writes to stdout if `None`.
        * encoding: Encoding of input and output files. Defaults to utf-8.

        uutf-8tmodeurtencodinguuwterrorsuxmlcharrefreplace(R5RR6tcodecstopent	getreadertreadtclosetsyststdinRhtdecodetlstripR~twritet	getwritertencodetstdouttbufferRN(	R'tinputRzR€t
input_filettextthtmltoutput_filetwriter((s/build/lib.linux-x86_64-2.7/markdown/__init__.pytconvertFile’s8
	


N(R>R=t__doc__RqRRRRR`t
ESCAPED_CHARSR/R R$R7R\R&R%R~R?R–(((s/build/lib.linux-x86_64-2.7/markdown/__init__.pyR
8s4

	R				d		
		FcO@st||Ž}|j|ƒS(uÔConvert a Markdown string to HTML and return HTML as a Unicode string.

    This is a shortcut function for `Markdown` class to cover the most
    basic use case.  It initializes an instance of Markdown, loads the
    necessary extensions and runs the parser on the given text.

    Keyword arguments:

    * text: Markdown formatted text as Unicode or ASCII string.
    * Any arguments accepted by the Markdown class.

    Returns: An HTML document as a string.

    (R
R~(R’R(R)tmd((s/build/lib.linux-x86_64-2.7/markdown/__init__.pytmarkdownÞscO@sÐddddg}d}xO|D]G}|||krF||||<n|d7}|t|ƒkrPqqWt|ƒr‰tjdtƒnt|}|j|jddƒ|jddƒ|jddƒƒdS(	u¤Read markdown code from a file and write it to a file or a stream.

    This is a shortcut function which initializes an instance of Markdown,
    and calls the convertFile method rather than convert.

    Keyword arguments:

    * input: a file name or readable object.
    * output: a file name or writable object.
    * encoding: Encoding of input and output.
    * Any arguments accepted by the Markdown class.

    uinputuoutputu
extensionsuencodingiiusPositional arguments are depreacted in Markdown and will raise an error in version 2.7. Use keyword arguments only.N(RRRRR
R–RR?(R(R)R*R+R,R™((s/build/lib.linux-x86_64-2.7/markdown/__init__.pytmarkdownFromFileñs

	
($R—t
__future__RRt__version__RRR‚R‡tloggingRRGtRR0RtblockprocessorsRR3RtinlinepatternsRR4R	RR
tserializersRRt__all__t	getLoggerR:tobjectR
RšR›(((s/build/lib.linux-x86_64-2.7/markdown/__init__.pyt<module>s,ÿ§