Mercurial > hg > TextShaper
changeset 43:21b6a9569f21
onelineit
author | Jeff Hammel <k0scist@gmail.com> |
---|---|
date | Wed, 03 Sep 2014 18:13:15 -0700 |
parents | 1a80204bd562 |
children | 8addd6e12b29 |
files | textshaper/main.py textshaper/onelineit.py |
diffstat | 2 files changed, 5 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/textshaper/main.py Mon Aug 25 19:31:16 2014 -0700 +++ b/textshaper/main.py Wed Sep 03 18:13:15 2014 -0700 @@ -12,6 +12,7 @@ import time from .commands import Commands from .indent import deindent, indent +from .onelineit import onelineit from .tablify import make_csv from .whitespace import underscore from which import which @@ -41,6 +42,7 @@ commands = Commands() commands.add(indent, 'i') commands.add(deindent, 'd') + commands.add(onelineit, 'o') commands.add(underscore, 'u') commands.add(make_csv, 'c') return commands
--- a/textshaper/onelineit.py Mon Aug 25 19:31:16 2014 -0700 +++ b/textshaper/onelineit.py Wed Sep 03 18:13:15 2014 -0700 @@ -5,17 +5,18 @@ """ import sys +from .decorator import lines +@lines def onelineit(string): """make a string one line""" - string = string.split('\n') string = [ i.strip() or '\n' for i in string ] string = ' '.join(string) string = string.split('\n') string = [ i.strip() for i in string if i.strip() ] - return '\n\n'.join(string) + return '\n\n'.join(string).splitlines() def main(args=sys.argv[1:]): """CLI"""