Saturday, March 31, 2007

Testing pygments

This is a test post to see experiment with the code hightlighting output from pygments.org (as recommended by a couple of commentors on my previous post). Pygments produces HTML with CSS-based styling, so I have added a bunch of new styles to my blogger template. And I am including as a sample the same Python code posted earlier with the alternative syntax highlighting tool.

    def main(self, *m3ufilenames):

self.startRSS()
self.generateChannelInfo()

for line in fileinput.input(m3ufilenames):
mp3filename = line.strip()
if not mp3filename or mp3filename.startswith('#'):
continue
self.generateItem(mp3filename)

self.endRSS()

return 0


So, let me know what you think of the 2 methods, and which looks better.

1 comments:

Matt Good said...

Well, after integrating Pygments with Trac and writing a couple lexers I *really* like it a lot more than other code highlighters I've worked with. Pygments also uses classes instead of inline styles like whatever you were using before, so it should save on bandwidth and make it easy to tweak the CSS. There are other themes included with Pygments, so if you don't like those colors it's pretty easy to change. You can paste some code and try the different themes at pygments.org, I like "native" myself:
http://pygments.org/demo/14/?style=native