File tree 1 file changed +7
-0
lines changed
1 file changed +7
-0
lines changed Original file line number Diff line number Diff line change @@ -49,6 +49,8 @@ def chunks(lst, n):
49
49
the_line = ""
50
50
for w in words :
51
51
if len (w ) > max_chars :
52
+ if the_line : # add what we had stored
53
+ the_lines .append (the_line )
52
54
parts = []
53
55
for part in chunks (w , max_chars - 1 ):
54
56
parts .append ("{}-" .format (part ))
@@ -58,11 +60,16 @@ def chunks(lst, n):
58
60
59
61
if len (the_line + " " + w ) <= max_chars :
60
62
the_line += " " + w
63
+ elif not the_line and len (w ) == max_chars :
64
+ the_lines .append (w )
61
65
else :
62
66
the_lines .append (the_line )
63
67
the_line = "" + w
64
68
if the_line : # Last line remaining
65
69
the_lines .append (the_line )
70
+ # Remove any blank lines
71
+ while not the_lines [0 ]:
72
+ del the_lines [0 ]
66
73
# Remove first space from first line:
67
74
if the_lines [0 ][0 ] == " " :
68
75
the_lines [0 ] = the_lines [0 ][1 :]
You can’t perform that action at this time.
0 commit comments