Tim Hatch

Weblog | Photos | Projects | Panoramas | About

Pygmentizing a directory at once 30 May, 2009

Zed Shaw posted recently about how things are confusing in Python. Just a couple of notes, for the benefit of people in such situations:

The opposite of list.append(x) is more likely list.pop([position]) which removes and returns the item.

If you want to syntax highlight a directory of files, Pygments can most certainly do that:

pygmentize -f html -S trac > trac.css
for f in *.py; do
    pygmentize -f html -O full -O cssfile=trac.css -o "${f/%\.py/.html}" "$f"
done

The fancy substitution on the argument for -o is bash-specific, so adjust for your shell.