Code snippets test If Pygments is installed, you can generate colorized code snippets using, for example, ...]]>. Pygments supports many, many different lexers. class code(MapNode): def evaluate(self, tagname, sdict, pcontent, extra, context): stylename = "pre.defaultStyle" if sdict.has_key("style"): stylename = sdict["style"] if sdict.has_key("syntax"): lang = sdict["syntax"] #clean up the block of code prior to display. src = ''.join(map(str, pcontent)) #split line ends, strip trailing space lines = map(lambda x: x.rstrip(), src.split('\n')) #generally we trim off up to one leading and trailing blank lines #that's probably from indenting the XML if lines[0] == '': lines = lines[1:] if lines[-1] == '': lines = lines[:-1] Now we'll show colourised XML: Foo bar! ]]> If you don't specify a language parameter, it won't get colourised. Foo bar! ]]> Because your XML might be indented, by default we remove an initial or final blank line, and we also 'dedent' to remove any whitespace on the left of your code block. However, the default paragraph style selected adds an indent on the left side. The one below specifies a different paragraph style, defined in our document, to add a coloured backdrop... def my_function(arg): foo, bar = do_stuff_to(arg) return [bar, foo[0]]