Did I find the right examples for you? yes no      Crawl my project      Python Jobs

All Samples(8)  |  Call(6)  |  Derive(0)  |  Import(2)

        def pygmentify_html(text, **kwargs):
    text = smart_unicode(text)
    lang = default_lang = 'text'
    # a tuple of known lexer names
    lexer_names = reduce(lambda a,b: a + b[2], LEXERS.itervalues(), ())
    # custom formatter
    formatter = ListHtmlFormatter(encoding='utf-8', **kwargs)
    subs = []
    pre_re = re.compile(r'(]*>)(.*?)(
)', re.DOTALL | re.UNICODE) br_re = re.compile(r']*?>', re.UNICODE) lang_re = re.compile(r'lang="(.+?)"', re.DOTALL | re.UNICODE) for pre_match in pre_re.findall(text): work_area = pre_match[1] work_area = br_re.sub('\n', work_area) match = lang_re.search (pre_match[0]) if match: lang = match.group(1).strip() if lang not in lexer_names: lang = default_lang lexer = get_lexer_by_name(lang, stripall=True) work_area = work_area.replace(u' ', u' ').replace(u'&', u'&').replace(u'<', u'<').replace(u'>', u'>').replace(u'"', u'"').replace(u''', u"'") work_area = highlight(work_area, lexer, formatter) subs.append([u''.join(pre_match), smart_unicode(work_area)]) for sub in subs: text = text.replace(sub[0], sub[1], 1) return text


src/d/j/django-pygments-0.1/django_pygments/templatetags/pygmentify.py   django-pygments(Download)
from django import template
from django.template.defaultfilters import stringfilter
from django_pygments.utils import pygmentify_html
from django.utils.safestring import mark_safe
 
def pygmentify(value):
    try:
        res = pygmentify_html(value)
    except Exception, e:
        print e
def pygmentify_inline(value):
    try:
        res = pygmentify_html(value, noclasses=True)
    except Exception, e:
        print e
    def render(self, context):
        output = self.nodelist.render(context)
        try:
            res = pygmentify_html(output, **self.kwargs)
        except Exception, e:

src/d/j/django-pygments-HEAD/django_pygments/templatetags/pygmentify.py   django-pygments(Download)
from django import template
from django.template.defaultfilters import stringfilter
from django_pygments.utils import pygmentify_html
from django.utils.safestring import mark_safe
 
def pygmentify(value):
    try:
        res = pygmentify_html(value)
    except Exception, e:
        print e
def pygmentify_inline(value):
    try:
        res = pygmentify_html(value, noclasses=True)
    except Exception, e:
        print e
    def render(self, context):
        output = self.nodelist.render(context)
        try:
            res = pygmentify_html(output, **self.kwargs)
        except Exception, e: