Xc @ s d Z d d k Z y
e i Z Wn e j
o
d Z n Xd d d YZ d e i i f d YZ d e i f d YZ h d
Z
d S( s
CodeHilite Extension for Python-Markdown
========================================
Adds code/syntax highlighting to standard Python-Markdown code blocks.
Copyright 2006-2008 [Waylan Limberg](http://achinghead.com/).
Project website:
Contact: markdown@freewisdom.org
License: BSD (see ../docs/LICENSE for details)
Dependencies:
* [Python 2.3+](http://python.org/)
* [Markdown 2.0+](http://www.freewisdom.org/projects/python-markdown/)
* [Pygments](http://pygments.org/)
iNi t
CodeHilitec B sD e Z d Z d e d d Z d Z d Z d Z d Z RS( s
Determine language of source code, and pass it into the pygments hilighter.
Basic Usage:
>>> code = CodeHilite(src = 'some text')
>>> html = code.hilite()
* src: Source string or any object with a .readline attribute.
* linenos: (Boolen) Turn line numbering 'on' or 'off' (off by default).
* css_class: Set class name of wrapper div ('codehilite' by default).
Low Level Usage:
>>> code = CodeHilite()
>>> code.src = 'some text' # String or anything with a .readline attr.
>>> code.linenos = True # True or False; Turns line numbering on or of.
>>> html = code.hilite()
t
codehilitec C s( | | _ d | _ | | _ | | _ d S( N( t srct Nonet langt linenost css_class( t selfR R R ( ( sB /usr/lib/python2.6/site-packages/markdown/extensions/codehilite.pyt __init__7 s c C sE | i i d | _ | i y@ d d k l } d d k l } l } l } d d k l
} WnV t j
oJ | i | i } | i
o | i | } n d | i | f } | SXy | | i } WnE t j
o9 y | | i } Wqt j
o | } qXn X| d | i
d | i } | | i | | Sd S(
s?
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.: ).
returns : A string of html.
s
i( t highlight( t get_lexer_by_namet guess_lexert TextLexer( t
HtmlFormatters$
R t cssclassN( R t stript _getLangt pygmentsR t pygments.lexersR
R R t pygments.formattersR
t ImportErrort _escapeR t _numberR R t
ValueError( R R R
R R R
t txtt lexert formatter( ( sB /usr/lib/python2.6/site-packages/markdown/extensions/codehilite.pyt hilite= s.
c C sL | i d d } | i d d } | i d d } | i d d } | S( s basic html escaping t &s &t