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 / treeprocessors.pyc
Size: Mime:
ó
Âö™Wc@@s«ddlmZddlmZddlmZddlmZddlmZd„Zd„Zd	ej	fd
„ƒYZ
de
fd„ƒYZd
e
fd„ƒYZdS(i(tunicode_literals(tabsolute_importi(tutil(todict(tinlinepatternscK@s0tjƒ}t|ƒ|d<t|ƒ|d<|S(u0 Build the default treeprocessors for Markdown. uinlineuprettify(RtOrderedDicttInlineProcessortPrettifyTreeprocessor(tmd_instancetkwargsttreeprocessors((s5build/lib.linux-x86_64-2.7/markdown/treeprocessors.pytbuild_treeprocessorsscC@s&t|tjƒs"t|tjƒStS(u Check if it's string (t
isinstanceRtAtomicStringtstring_typetFalse(ts((s5build/lib.linux-x86_64-2.7/markdown/treeprocessors.pytisStringst
TreeprocessorcB@seZdZd„ZRS(u'
    Treeprocessors are run on the ElementTree object before serialization.

    Each Treeprocessor implements a "run" method that takes a pointer to an
    ElementTree, modifies it as necessary and returns an ElementTree
    object.

    Treeprocessors must extend markdown.Treeprocessor.

    cC@sdS(u 
        Subclasses of Treeprocessor should implement a `run` method, which
        takes a root ElementTree. This method can return another ElementTree
        object, and the existing root ElementTree will be replaced, or it can
        modify the current tree and return None.
        N((tselftroot((s5build/lib.linux-x86_64-2.7/markdown/treeprocessors.pytrun"s(t__name__t
__module__t__doc__R(((s5build/lib.linux-x86_64-2.7/markdown/treeprocessors.pyRs
RcB@skeZdZd„Zd„Zd„Zd„Zdd„Zed„Z	ed„Z
dd	„Zd
„ZRS(uJ
    A Treeprocessor that traverses a tree, applying inline patterns.
    cC@s`tj|_tj|_dt|jƒt|jƒ|_tj|_||_	|j
|_
dS(Ni(RtINLINE_PLACEHOLDER_PREFIXt$_InlineProcessor__placeholder_prefixtETXt$_InlineProcessor__placeholder_suffixtlent$_InlineProcessor__placeholder_lengthtINLINE_PLACEHOLDER_REt _InlineProcessor__placeholder_retmarkdowntinlinePatterns(Rtmd((s5build/lib.linux-x86_64-2.7/markdown/treeprocessors.pyt__init__1s#	cC@s*dt|jƒ}tj|}||fS(u Generate a placeholder u%04d(Rt
stashed_nodesRtINLINE_PLACEHOLDER(Rttypetidthash((s5build/lib.linux-x86_64-2.7/markdown/treeprocessors.pyt__makePlaceholder:s
cC@sF|jj||ƒ}|r4|jdƒ|jƒfSd|dfSdS(u÷
        Extract id from data string, start from index

        Keyword arguments:

        * data: string
        * index: index, from which we start search

        Returns: placeholder id and string index, after the found placeholder.

        iN(R tsearchtgrouptendtNone(Rtdatatindextm((s5build/lib.linux-x86_64-2.7/markdown/treeprocessors.pyt__findPlaceholder@scC@s&|j|ƒ\}}||j|<|S(u Add node to stash (t!_InlineProcessor__makePlaceholderR%(RtnodeR'tplaceholderR(((s5build/lib.linux-x86_64-2.7/markdown/treeprocessors.pyt__stashNodeRs
icC@s{t|tjƒswd}x\|t|jƒkrs|j|jj|ƒ|||ƒ\}}}|s|d7}qqWn|S(u
        Process string with inline patterns and replace it
        with placeholders

        Keyword arguments:

        * data: A line of Markdown text
        * patternIndex: The index of the inlinePattern to start with

        Returns: String with placeholders.

        ii(RRR
RR"t_InlineProcessor__applyPatterntvalue_for_index(RR/tpatternIndext
startIndextmatched((s5build/lib.linux-x86_64-2.7/markdown/treeprocessors.pyt__handleInlineXs
cC@s¦|r|j}d|_n|j}d|_|j|||ƒ}|rq||k	rqt|ƒj|ƒd}nd}|jƒx|D]}|j||ƒqˆWdS(u4
        Process placeholders in Element.text or Element.tail
        of Elements popped from self.stashed_nodes.

        Keywords arguments:

        * node: parent node
        * subnode: processing node
        * isText: bool variable, True - it's text, False - it's tail

        Returns: None

        iiN(ttextR.ttailt%_InlineProcessor__processPlaceholderstlistR0treversetinsert(RR4tsubnodetisTextR=tchildResulttpostnewChild((s5build/lib.linux-x86_64-2.7/markdown/treeprocessors.pyt__processElementTextos			

c
@sÒ‡‡‡fd†}g‰d}xª|rÍ|j|j|ƒ}|dkrŒ|j||ƒ\}}||jkr_|jj|ƒ}	|dkrª|||!}
||
ƒnt|	ƒs6x|	gt|	ƒD]e}|jr|jjƒr|j	|	|t
ƒqn|jrÊ|jjƒr/|j	||ƒq/qÊqÊWn||	ƒ|}q$|}ˆj|	ƒqÊ|t
|jƒ}||||!ƒ|}q$||}
t|tjƒrºtj|
ƒ}
n||
ƒd}q$WˆS(uI
        Process string with placeholders and generate ElementTree tree.

        Keyword arguments:

        * data: string with placeholders instead of ElementTree elements.
        * parent: Element, which contains processing inline data

        Returns: list with ElementTree elements with applied inline patterns.

        c@s—|r“ˆr?ˆdjr/ˆdj|7_q|ˆd_q“ˆslˆjr`ˆj|7_q|ˆ_q“ˆjr‡ˆj|7_q“|ˆ_ndS(Niÿÿÿÿ(R>R=(R=(RDtparenttresult(s5build/lib.linux-x86_64-2.7/markdown/treeprocessors.pytlinkText›s
		iiÿÿÿÿu(tfindRt!_InlineProcessor__findPlaceholderR%tgetRR@R>tstript$_InlineProcessor__processElementTextRR=tappendRRRR
(
RR/RIRDRKtstrartIndexR0R(t
phEndIndexR4R=tchildR-((RDRIRJs5build/lib.linux-x86_64-2.7/markdown/treeprocessors.pyt__processPlaceholderssF	

		
	


c
C@si|jƒj||ƒ}|| }|s6|tdfS|j|ƒ}|dkr|tt|ƒ|jt|jƒƒƒdfSt	|ƒs!t
|jtj
ƒs!xy|gt|ƒD]a}t	|ƒs¶|jrð|j|j|dƒ|_n|jr|j|j|ƒ|_qq¶q¶Wq!n|j||jƒƒ}	d||jdƒ|	|jƒdftdfS(u¨
        Check if the line fits the pattern, create the necessary
        elements, add it to stashed_nodes.

        Keyword arguments:

        * data: the text to be processed
        * pattern: the pattern to be checked
        * patternIndex: index of current pattern
        * startIndex: string index, from which we start searching

        Returns: String with placeholders instead of ElementTree elements.

        iiu%s%s%s%siÿÿÿÿN(tgetCompiledRegExptmatchRthandleMatchR.tTrueRtspantgroupsRRR=RR
R@t_InlineProcessor__handleInlineR>t_InlineProcessor__stashNodeR'R,(
RtpatternR/R9R:RWtleftDataR4RTR5((s5build/lib.linux-x86_64-2.7/markdown/treeprocessors.pyt__applyPatternÚs*

0		"cC@swi|_|g}x^|rr|jƒ}g}x@|D]8}|jr¦t|jtjƒr¦|j}d|_|j|j|ƒ|ƒ}||7}|j	||fƒn|j
rP|j|j
ƒ}tjjdƒ}	d|_
|j||	t
ƒ}
|	j
r	|	j
|_
nt|ƒj|ƒd}|
jƒx!|
D]}|j||ƒq3Wnt|ƒr4|j	|ƒq4q4Wxü|D]ô\}
}|jjrÅ|
jrÅt|
jƒrÅtj|
j|
ƒ|
_qÅnd}x|D]•}|jjrM|j
rt|j
ƒrtj|j
|
ƒ|_
n|jrMt|jƒrMtj|j|ƒ|_qMn|
j||ƒ|d7}qÒWqwWqW|S(u-Apply inline patterns to a parsed Markdown tree.

        Iterate over ElementTree, find elements with inline tag, apply inline
        patterns and append newly created Elements to tree.  If you don't
        want to process your data with inline paterns, instead of normal
        string, use subclass AtomicString:

            node.text = markdown.AtomicString("This will not be processed.")

        Arguments:

        * tree: ElementTree object, representing Markdown tree.

        Returns: ElementTree object with applied inline patterns.

        udiiN(R%tpopR=RRR
R.R?R\RQR>tetreetElementRR@R0RARBRR!tenable_attributesRRthandleAttributes(RttreetstacktcurrElementtinsertQueueRTR=tlstR>tdumbyt
tailResultRFRGtelementti((s5build/lib.linux-x86_64-2.7/markdown/treeprocessors.pyRsX			
		
			


(
RRRR$R3RMR]R\RYRPR?R7R(((s5build/lib.linux-x86_64-2.7/markdown/treeprocessors.pyR,s					 K.RcB@s eZdZd„Zd„ZRS(u& Add linebreaks to the html document. cC@sõd}tj|jƒrË|jdkrË|jsA|jjƒrot|ƒrotj|djƒro||_nx0|D](}tj|jƒrv|j|ƒqvqvW|js¼|jjƒrË||_qËn|jså|jjƒrñ||_ndS(u5 Recursively add linebreaks to ElementTree children. u
ucodeupreiN(ucodeupre(RtisBlockLevelttagR=RORt_prettifyETreeR>(RtelemRnte((s5build/lib.linux-x86_64-2.7/markdown/treeprocessors.pyRqSs!"
cC@sÐ|j|ƒ|jdƒ}xD|D]<}|jsC|jjƒrOd|_q#d|j|_q#W|jdƒ}xW|D]O}t|ƒry|djdkrytj|djj	ƒdƒ|d_qyqyWdS(u, Add linebreaks to ElementTree root object. ubru
u
%supreiucodeN(
RqtgetiteratorR>RORRpRR
R=trstrip(RRtbrstbrtprestpre((s5build/lib.linux-x86_64-2.7/markdown/treeprocessors.pyRcs


(RRRRqR(((s5build/lib.linux-x86_64-2.7/markdown/treeprocessors.pyRPs	N(
t
__future__RRtRRRRRt	ProcessorRRR(((s5build/lib.linux-x86_64-2.7/markdown/treeprocessors.pyt<module>s		ÿ%