Getting indented code snippets into blogger

P

Paddy

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top