'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.'

def hilite(self):

    self.src = self.src.strip(u'\n')
    if (self.lang is None):
        self._parseHeader()
    if (pygments and self.use_pygments):
        try:
            lexer = get_lexer_by_name(self.lang)
        except ValueError:
            try:
                if self.guess_lang:
                    lexer = guess_lexer(self.src)
                else:
                    lexer = get_lexer_by_name(u'text')
            except ValueError:
                lexer = get_lexer_by_name(u'text')
        formatter = get_formatter_by_name(u'html', linenos=self.linenums, cssclass=self.css_class, style=self.style, noclasses=self.noclasses, hl_lines=self.hl_lines)
        return highlight(self.src, lexer, formatter)
    else:
        txt = self.src.replace(u'&', u'&amp;')
        txt = txt.replace(u'<', u'&lt;')
        txt = txt.replace(u'>', u'&gt;')
        txt = txt.replace(u'"', u'&quot;')
        classes = []
        if self.lang:
            classes.append((u'language-%s' % self.lang))
        if self.linenums:
            classes.append(u'linenums')
        class_str = u''
        if classes:
            class_str = (u'    class="%s"' % u'    '.join(classes))
        return (u'<pre    class="%s"><code%s>%s</code></pre>\n' % (self.css_class, class_str, txt))
