Replacing spaces with dots for formatting code in coments
#dotify.py
#
#Insert dots instead of spaces and tabs
#in the begining of lines. This is to
#maintain formatting for code while
#commenting in sites that do not support
#formatting.
#
#usage:
#cat test.py | python dotify.py >> dotted.txt
#
import re
import sys
r = re.compile("^[ \t]+", re.MULTILINE)
def repFun(match):
return "."*len(match.group().replace("\t", " "*4))
print r.sub(repFun, sys.stdin.read())
0 Comments:
Post a Comment
<< Home