Commit db75afe6 authored by Greg Ward's avatar Greg Ward

Added collapse_ws option.

parent a4e6ae66
......@@ -23,6 +23,7 @@ class TextFile:
'join_lines': 0,
'lstrip_ws': 0,
'rstrip_ws': 1,
'collapse_ws': 0,
}
def __init__ (self, filename=None, **options):
......@@ -137,6 +138,10 @@ class TextFile:
buildup_line = line[0:-2] + '\n'
continue
# collapse internal whitespace (*after* joining lines!)
if self.collapse_ws:
line = re.sub (r'(\S)\s+(\S)', r'\1 \2', line)
# well, I guess there's some actual content there: return it
return line
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment