|
From: Dieter P. <di...@pl...> - 2010-11-01 09:51:07
|
On Mon, 1 Nov 2010 10:10:51 +1100 Pete Goldsmith <bon...@gm...> wrote: > What about writing a plugin that parses your <code> blocks and runs > them through something like http://pygments.org/ > > ? Thanks, that seems like a good idea. I've been looking at the markdown and linebreak parser plugins to see how to do it, but I can't get it to work. Just to get the first step working (modifying the page content), I use this code (comments stripped for clarity): __author__ = 'Dieter Plaetinck <di...@pl...>' __version__ = "0.1" PREFORMATTER_ID = 'pygments' import re def cb_preformat(args): if args['parser'] == PREFORMATTER_ID: return parse(''.join(args['story'])) def parse(text): text = re.sub('\n','<h1>somethinghappens</h1>',text) return text and my config: $ grep pygment /srv/http/dieterblog/config.py py["load_plugins"] = ["comments", "tags", 'pygments'] py['parser'] = 'pygments' the code is in this file: /srv/http/dieterblog/plugins/pygments.py Normally I should see "<h1>somethinghappens</h1>" all over the place, right? But my pages are the way they were before, as if it's still using the plain parser. When I use the debug renderer it confirms that Request.get_configuration() dict contains parser -> pygments No errors in my lighttpd error log either. Dieter |