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 / extensions / codehilite.pyc
Size: Mime:
ó
Âö™Wc@@sødZddlmZddlmZddlmZddlmZy@ddlm	Z	dd	l
mZmZdd
l
mZeZWnek
rŸeZnXd„Zdefd
„ƒYZdefd„ƒYZdefd„ƒYZd„ZdS(uÂ
CodeHilite Extension for Python-Markdown
========================================

Adds code/syntax highlighting to standard Python-Markdown code blocks.

See <https://pythonhosted.org/Markdown/extensions/code_hilite.html>
for documentation.

Original code Copyright 2006-2008 [Waylan Limberg](http://achinghead.com/).

All changes Copyright 2008-2014 The Python Markdown Project

License: [BSD](http://www.opensource.org/licenses/bsd-license.php)

i(tabsolute_import(tunicode_literalsi(t	Extensioni(t
Treeprocessor(t	highlight(tget_lexer_by_nametguess_lexer(tget_formatter_by_namecC@s@|s
gSyttt|jƒƒƒSWntk
r;gSXdS(uÄSupport our syntax for emphasizing certain lines of code.

    expr should be like '1 2' to emphasize lines 1 and 2 of a code block.
    Returns a list of ints, the line numbers to emphasize.
    N(tlisttmaptinttsplitt
ValueError(texpr((s<build/lib.linux-x86_64-2.7/markdown/extensions/codehilite.pytparse_hl_lines s
t
CodeHilitecB@sGeZdZddedddedded„
Zd„Zd„ZRS(uL
    Determine language of source code, and pass it into pygments hilighter.

    Basic Usage:
        >>> code = CodeHilite(src = 'some text')
        >>> html = code.hilite()

    * src: Source string or any object with a .readline attribute.

    * linenums: (Boolean) Set line numbering to 'on' (True),
      'off' (False) or 'auto'(None). Set to 'auto' by default.

    * guess_lang: (Boolean) Turn language auto-detection
      'on' or 'off' (on by default).

    * css_class: Set class name of wrapper div ('codehilite' by default).

    * hl_lines: (List of integers) Lines to emphasize, 1-indexed.

    Low Level Usage:
        >>> code = CodeHilite()
        >>> code.src = 'some text' # String or anything with a .readline attr.
        >>> code.linenos = True  # Turns line numbering on or of.
        >>> html = code.hilite()

    u
codehiliteudefaulticC@sd||_||_||_||_||_||_||_||_|	pQg|_|
|_	dS(N(
tsrctlangtlinenumst
guess_langt	css_clasststylet	noclassest
tab_lengththl_linestuse_pygments(tselfRRRRRRRRRR((s<build/lib.linux-x86_64-2.7/markdown/extensions/codehilite.pyt__init__Ls								c
C@sÂ|jjdƒ|_|jdkr1|jƒntrþ|jrþyt|jƒ}Wn\tk
r±y+|j	rt
|jƒ}ntdƒ}Wq²tk
r­tdƒ}q²XnXtdd|jd|j
d|jd|jd|jƒ}t|j||ƒS|jjd	d
ƒ}|jddƒ}|jd
dƒ}|jddƒ}g}|jro|jd|jƒn|jrˆ|jdƒnd}|rªddj|ƒ}nd|j
||fSdS(u7
        Pass code to the [Pygments](http://pygments.pocoo.org/) highliter with
        optional line numbers. The output should then be styled with css to
        your liking. No styles are applied by default - only styling hooks
        (i.e.: <span class="k">).

        returns : A string of html.

        u
utextuhtmltlinenostcssclassRRRu&u&amp;u<u&lt;u>u&gt;u"u&quot;ulanguage-%sulinenumsuu class="%s"u u(<pre class="%s"><code%s>%s</code></pre>
N(RtstripRtNonet_parseHeadertpygmentsRRRRRRRRRRRRtreplacetappendtjoin(Rtlexert	formatterttxttclassest	class_str((s<build/lib.linux-x86_64-2.7/markdown/extensions/codehilite.pythiliteZsD

	
							cC@s&ddl}|jjdƒ}|jdƒ}|jd|jƒ}|j|ƒ}|r÷y|jdƒjƒ|_	Wnt
k
rd|_	nX|jdƒr²|jd|ƒn|j
dkrÜ|jdƒrÜt|_
nt|jdƒƒ|_n|jd|ƒdj|ƒjdƒ|_dS(	uD
        Determines language of a code block from shebang line and whether said
        line should be removed or left in place. If the sheband line contains a
        path (even a single /) then it is assumed to be a real shebang line and
        left alone. However, if no path is given (e.i.: #!python or :::python)
        then it is assumed to be a mock shebang for language identifitation of
        a code fragment and removed from the code block prior to processing for
        code highlighting. When a mock shebang (e.i: #!python) is found, line
        numbering is turned on. When colons are found in place of a shebang
        (e.i.: :::python), line numbering is left in the current state - off
        by default.

        Also parses optional list of highlight lines, like:

            :::python hl_lines="1 3"
        iNu
uœ
            (?:(?:^::+)|(?P<shebang>^[#]!)) # Shebang or 2 or more colons
            (?P<path>(?:/\w+)*[/ ])?        # Zero or 1 path
            (?P<lang>[\w+-]*)               # The language
            \s*                             # Arbitrary whitespace
            # Optional highlight lines, single- or double-quote-delimited
            (hl_lines=(?P<quot>"|')(?P<hl_lines>.*?)(?P=quot))?
            ulangupathushebanguhl_lines(treRRtpoptcompiletVERBOSEtsearchtgrouptlowerRt
IndexErrorRtinsertRtTrueRRR$R(RR+tlinestfltctm((s<build/lib.linux-x86_64-2.7/markdown/extensions/codehilite.pyR s$

N(	t__name__t
__module__t__doc__RR4tFalseRR*R (((s<build/lib.linux-x86_64-2.7/markdown/extensions/codehilite.pyR0s			3tHiliteTreeprocessorcB@seZdZd„ZRS(u% Hilight source code in code blocks. cC@sö|jdƒ}xà|D]Ø}t|ƒdkr|djdkrt|djd|jdd|jdd	|jd
d|jdd
|jdd|jjd|jdƒ}|jjj	|j
ƒdtƒ}|jƒd|_||_qqWdS(u* Find code blocks and store in htmlStash. upreiiucodeRulinenumsRu
guess_langRu	css_classRupygments_styleRu	noclassesRRuuse_pygmentstsafeupN(
titertlenttagRttexttconfigtmarkdownRt	htmlStashtstoreR*R4tclear(Rtroottblockstblocktcodetplaceholder((s<build/lib.linux-x86_64-2.7/markdown/extensions/codehilite.pytrunËs"
%





	
	(R9R:R;RM(((s<build/lib.linux-x86_64-2.7/markdown/extensions/codehilite.pyR=ÈstCodeHiliteExtensioncB@s eZdZd„Zd„ZRS(u4 Add source code hilighting to markdown codeblocks. cO@stiddgd6tdgd6ddgd6dd	gd
6tdgd6td
gd6|_tt|ƒj||ŽdS(Nu0Use lines numbers. True=yes, False=no, None=autoulinenumsu,Automatic language detection - Default: Trueu
guess_langu
codehiliteu6Set class name for wrapper <div> - Default: codehiliteu	css_classudefaultu>Pygments HTML Formatter Style (Colorscheme) - Default: defaultupygments_styleu8Use inline styles instead of CSS classes - Default falseu	noclassesu[Use Pygments to Highlight code blocks. Disable if using a JavaScript library. Default: Trueuuse_pygments(RR4R<RCtsuperRNR(Rtargstkwargs((s<build/lib.linux-x86_64-2.7/markdown/extensions/codehilite.pyRçs




cC@sBt|ƒ}|jƒ|_|jjd|dƒ|j|ƒdS(u/ Add HilitePostprocessor to Markdown instance. uhiliteu<inlineN(R=t
getConfigsRCttreeprocessorstaddtregisterExtension(Rtmdt
md_globalsthiliter((s<build/lib.linux-x86_64-2.7/markdown/extensions/codehilite.pytextendMarkdownÿs(R9R:R;RRY(((s<build/lib.linux-x86_64-2.7/markdown/extensions/codehilite.pyRNäs	cO@s
t||ŽS(N(RN(RPRQ((s<build/lib.linux-x86_64-2.7/markdown/extensions/codehilite.pyt
makeExtensionsN(R;t
__future__RRtRRSRR!Rtpygments.lexersRRtpygments.formattersRR4tImportErrorR<RtobjectRR=RNRZ(((s<build/lib.linux-x86_64-2.7/markdown/extensions/codehilite.pyt<module>s 


	˜$