Re: showing source code in blog posts
Dieter Plaetinck <dieter-7FYLOmueu/[email protected]> Mon, 1 Nov 2010 10:50:58 +0100
| Newsgroups | gmane.comp.web.pyblosxom.user |
|---|---|
| Message-ID | <[email protected]> |
On Mon, 1 Nov 2010 10:10:51 +1100 Pete Goldsmith <[email protected]> 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 <dieter-7FYLOmueu/[email protected]>' __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 ------------------------------------------------------------------------------ Nokia and AT&T present the 2010 Calling All Innovators-North America contest Create new apps & games for the Nokia N8 for consumers in U.S. and Canada $10 million total in prizes - $4M cash, 500 devices, nearly $6M in marketing Develop with Nokia Qt SDK, Web Runtime, or Java and Publish to Ovi Store http://p.sf.net/sfu/nokia-dev2dev