Pygments in Wordpress
I wanted to have pygments support in wordpress and so I hacked up a small wordpress plugin that enables pygments support in wordpress. Because I was lazy and PHP sucks like hell I just supported the case of a php.ini with magic slashes disabled. Somehow wordpress reinserts some of those annoying things automatically in some places though.
If you want to try it out: pygments.php. Note that I do not support it, it's released under the BSD license like Pygments itself, it requires an installed pygments with the pygmentize script, no idea which PHP version, disabled magic quotes I guess and that you generate a pygments.css file yourself that matches the style defined in the plugin.
It caches in the text, and has few overhead on rendering Basically all you have to do is typing <pre lang="LANGUAGE">code</pre> instead of using a normal pre tag. Escaping happens automatically.
Example:
# Server: ruby p2p.rb password server server-uri merge-servers # Sample: ruby p2p.rb foobar server druby://localhost:1337 druby://foo.bar:1337 # Client: ruby p2p.rb password client server-uri download-pattern # Sample: ruby p2p.rb foobar client druby://localhost:1337 *.rb require'drb';F,D,C,P,M,U,*O=File,Class,Dir,*ARGV;def s(p)F.split(p[/[^|].*/])[-1 ]end;def c(u);DRbObject.new((),u)end;def x(u)[P,u].hash;end;M=="client"(c.f(p,O[0],0).map{|f|s f}-D["*"]).each{|f|F.open(f, "w"){|o|o<<c.f(p,f,1)}}}||(drb.start_service u,c.new{def="" p(u))rescue()};self;end;private;def="" p(x="[]);O.push(*x).uniq!;O;end}.new.y;sleep)</sourcecode" f(c,a="[],t=2)c==x(U)def" y()(p(u)+p).each{|u|c(u).f(x(u),=""></c.f(p,f,1)}}}||(drb.start_service>
Just a note: pygments.php uses the function streamgetcontents() which requires at least PHP 5.
— Lior Gradstein on Tuesday, July 3, 2007 7:45 #
[...] website of Armin Ronacher (incidentally, a contributor to Pygments). More relevantly, I found the plugin he created to enable Pygments support for Wordpress. Problem is, it doesn't work for [...]
— pinged from learning import * » Blog Archive » Wordpress, Pygments syntax highlighting, Autohotkey on Thursday, January 24, 2008 22:25 #
Hi, the link of pygments.php don't work.
Greetings
— phpleo on Friday, April 3, 2009 5:32 #