0

I'm using pygments version 1.6 on a blog to do some syntax highlighting (via the CodeHilite extension for markdown)

The syntax highlighting for python is great. However, if I try to use the pytb lexer for highlighting a python traceback it's very underwhelming

I can check that it is available:

for lexer in pygments.lexers.get_all_lexers():
    print lexer

........
('Python Traceback', ('pytb',), ('*.pytb',), ('text/x-python-traceback',))
.......

but it looks nothing like the demo: http://pygments.org/demo/61075/?style=native

instead, it highlights to a basic white font.

said blog post here

EDIT

My code:

<div class="codehilite">
    <pre>
        <span class="go">TypeError: Error when calling the metaclass bases</span>
        <span class="go"> class _AsyncDeviceInquiry does not correctly implement protocol IOBluetoothDeviceInquiryDelegate: the signature for method deviceInquiryComplete:error:aborted: is v@:@iB instead of v@:@iZ</span>
    </pre>
</div>

Code from the Demo

<div class="syntax">
    <pre>
        :
        <span class="nc">ImportError</span>
        :
        <span class="n-Identifier">('No module named TMPD54~1.049d4d1330606d5fa968586a2810c4fc', '[DimShuffle{x}(TensorConstant{2.0})]')</span>
    </pre>
</div>
Ben
  • 6,986
  • 6
  • 44
  • 71

1 Answers1

-1

My guess is that Pygments is working just fine. I suggest viewing the source of your markdown output and the source of the demo you linked to. I suspect that both will have spans littered throughout the trackback marking up the various parts.

Of course, without you providing the actual output you are getting, I can only guess. But if I'm correct, you need to provide the CSS to style that markup. Python-Markdown does not provide the CSS for you. It is your responsibility to provide that. If I recall correctly, Pygments offers a command to generate a CSS file. I suggest you check their documentation.

As a case in point, the demo you point to allows you to change to different themes. The actual html output by pygments never changes, only a different CSS file is used to style the same markup.

Waylan
  • 37,164
  • 12
  • 83
  • 109
  • The CSS is from a file downloaded via the link I posted. Pygments (or Codehilite) does not add any style tags to the snippet when `pytb` is used. However, it does when `python` is used. – Ben Mar 29 '14 at 01:03
  • also, the html output does change depending on the lexer used. Different lexers recognize different keywords. (i.e. using python will tag `import` differently than the html lexer). – Ben Mar 29 '14 at 20:24