Getting indented code snippets into blogger

Paddy paddy3118 at googlemail.com
Tue Sep 18 09:12:51 CEST 2007


I got tired of Bloggers inadequate comment editor so wrote this for
transforming code snippets:

=========================
'''
blogspace.py
Turns leading spaces into HTML &nbsp tokens which shows
as correct indentation on Blogger comment fields
(and maybe other blogs).

Donald. 'Paddy' McCarthy Sept 2011
'''
import fileinput, re


for l in fileinput.input():
  print re.sub(r'^(\s*)\s',
               lambda m: ' '*m.end(),
               l.rstrip())
=========================

If you find it works on other blogs then please reply.to this thread.

- Paddy.




More information about the Python-list mailing list