Skip to content

Commit

Permalink
fix: indent would ignore first set to empty string.
Browse files Browse the repository at this point in the history
  • Loading branch information
vaab committed Feb 4, 2015
1 parent af7a773 commit 965371e
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/kids/txt/txt.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,18 +47,22 @@ def indent(text, prefix=" ", first=None):
>>> string = 'This is first line.\\nThis is second line\\n'
>>> print(indent(string, prefix="| ")) # doctest: +NORMALIZE_WHITESPACE
>>> print(indent(string, prefix="| "))
| This is first line.
| This is second line
|
>>> print(indent(string, first="- ")) # doctest: +NORMALIZE_WHITESPACE
>>> print(indent(string, first="- "))
- This is first line.
This is second line
>>> print(indent(string, first="")) ## doctest: -NORMALIZE_WHITESPACE
This is first line.
This is second line
<BLANKLINE>
"""
if first:
if first is not None:
first_line = text.split("\n")[0]
rest = '\n'.join(text.split("\n")[1:])
return '\n'.join([first + first_line,
Expand Down

0 comments on commit 965371e

Please sign in to comment.