15. April 2010

Syntaxhervorhebung mit Pygments

Nach ziemlich vielem Basteln ist die erste Version eines Syntax-Highlighting-Plugins für Textpattern fertig geworden. Das Ergebnis sieht zum Beispiel so aus:

#!/usr/bin/env python
# -*- coding: utf-8 -*-

from math import sqrt

def hypotenuse(a, b):
    """Calculates the hypotenuse given the
    two legs of a right triangle."""
    return sqrt(a*a + b*b)

print hypotenuse(3.0, 4.0)