summaryrefslogtreecommitdiff
path: root/squeeze.py
diff options
context:
space:
mode:
Diffstat (limited to 'squeeze.py')
-rw-r--r--squeeze.py29
1 files changed, 29 insertions, 0 deletions
diff --git a/squeeze.py b/squeeze.py
new file mode 100644
index 0000000..ce56a86
--- /dev/null
+++ b/squeeze.py
@@ -0,0 +1,29 @@
+import re
+import sys
+
+output = ''
+
+while True:
+ line = sys.stdin.readline()
+ if not line: break
+ if line[0] == '#':
+ if output:
+ print output
+ output = ''
+ print line.strip()
+ else:
+ x = re.findall('\w+|\W',line)
+ for u in x:
+ if not u.isspace():
+ if len(output) + len(u) > 140:
+ print output
+ output = ''
+ if (re.match('\w',output[-1:]) and re.match('\w',u[:1])) or (output[-1:] == '=' and u[:1] == '-'):
+ if len(output) + 1 + len(u) > 140:
+ print output
+ output = ''
+ else:
+ output += ' '
+ output += u
+
+print output