Attachment 'colorer.py'
Download 1 """
2 MoinMoin - Processor for Syntax Highlighting using the
3 http://colorer.sf.net
4 by
5 belugin@mail.ru
6
7 based on
8
9 MoinMoin - Processor for Syntax Highlighting using the enscript
10
11 Copyright (c) 2002 by Won-Kyu Park <wkpark@kldp.org>
12 All rights reserved, see COPYING for details.
13
14 $Id$
15
16 Usage:
17 {{{#!colorer sql
18 select * from testTable where a='test string'
19 }}}
20 """
21 import os,re,string,sys,popen2
22
23 def process(request, formatter, lines):
24 type=string.strip(lines[0][9:])
25 del lines[0]
26 buff=string.join(lines, '\n')+'\n'
27
28 options='-dh -h -t%s' % type
29 cmd = 'colorer ' + options
30
31 try:
32 fromchild, tochild = popen2.popen4(cmd)
33 tochild.write(buff)
34 tochild.flush()
35 tochild.close()
36 fromchild.flush()
37 html = fromchild.readlines()
38 finally:
39 fromchild.close()
40
41 html=html[2:-4]
42 html='<PRE>'+string.join(html, '')+'</PRE>'
43
44 request.write(formatter.rawHTML(html))
Attached Files
To refer to attachments on a page, use attachment:filename, as shown below in the list of files. Do NOT use the URL of the [get] link, since this is subject to change and can break easily.You are not allowed to attach a file to this page.