import fileinput, re, cgi
def escape(lineiterator=fileinput.input,
cgi_escape=True, tag_with_pre=True, tag_with_br=False):
output = []
if tag_with_pre: output.append('<pre>\n')
for line in lineiterator:
if cgi_escape: line = cgi.escape(line)
line = re.sub(r'^(\s*)\s',
lambda m: ' '*m.end(),
line.rstrip())
output.append(line)
if tag_with_br:
output.append('<br>\n')
else:
output.append('\n')
if tag_with_pre: output.append('</pre>\n')
return ''.join(output)
Saturday, March 28, 2009
How to publish python code in blogger
Thanks to Paddy.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment