Skip to content

Commit

Permalink
0.8.3
Browse files Browse the repository at this point in the history
  • Loading branch information
jonathaneunice committed Jun 14, 2017
1 parent d611663 commit 264aee1
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 3 deletions.
7 changes: 7 additions & 0 deletions CHANGES.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
-
version: 0.8.3
date: June 14, 2017
notes: >
Fixed edge case in `shorten()` reported by
`MinchinWeb <https://github.com/MinchinWeb>`_
-
version: 0.8.2
date: June 11, 2017
Expand Down
2 changes: 2 additions & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,7 @@ include pytest.ini
include tox.ini
include .travis.yml
include CHANGES.yml
include LICENSE.txt
include AUTHORS
include demo.py
recursive-include test *.py
2 changes: 1 addition & 1 deletion ansiwrap/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from .core import *

__version__ = '0.8.2'
__version__ = '0.8.3'

2 changes: 2 additions & 0 deletions ansiwrap/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,8 @@ def shorten(text, width, **kwargs):
"""
w = a_textwrap.TextWrapper(width=width, max_lines=1, **kwargs)
unterm = w.wrap(' '.join(text.strip().split()))
if not unterm:
return ''
term = ansi_terminate_lines(unterm[:1])
return term[0]

Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ def lines(text):

setup(
name='ansiwrap',
version='0.8.2',
version='0.8.3',
author='Jonathan Eunice',
author_email='jonathan.eunice@gmail.com',
description="textwrap, but savvy to ANSI colors and styles",
Expand Down
8 changes: 7 additions & 1 deletion test/test_ansiwrap.py
Original file line number Diff line number Diff line change
Expand Up @@ -258,5 +258,11 @@ def test_doc_example():
'\x1b[32mand\x1b[0m\n\x1b[32mmay need to '
'be\x1b[0m\n\x1b[38;2;128;0;128mshortened a bit\x1b[0m')

assert (shorten(s, 20, placeholder='...') ==
assert (shorten(s, 20, placeholder='...') ==
'\x1b[31mthis string\x1b[0m \x1b[34mis...\x1b[0m')

def test_shorten_trivial():
assert shorten('', 79) == ''
assert shorten(' ', 50) == ''
assert shorten(' ', 55) == ''

0 comments on commit 264aee1

Please sign in to comment.