File tree Expand file tree Collapse file tree 1 file changed +7
-0
lines changed Expand file tree Collapse file tree 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):
4949 the_line = ""
5050 for w in words :
5151 if len (w ) > max_chars :
52+ if the_line : # add what we had stored
53+ the_lines .append (the_line )
5254 parts = []
5355 for part in chunks (w , max_chars - 1 ):
5456 parts .append ("{}-" .format (part ))
@@ -58,11 +60,16 @@ def chunks(lst, n):
5860
5961 if len (the_line + " " + w ) <= max_chars :
6062 the_line += " " + w
63+ elif not the_line and len (w ) == max_chars :
64+ the_lines .append (w )
6165 else :
6266 the_lines .append (the_line )
6367 the_line = "" + w
6468 if the_line : # Last line remaining
6569 the_lines .append (the_line )
70+ # Remove any blank lines
71+ while not the_lines [0 ]:
72+ del the_lines [0 ]
6673 # Remove first space from first line:
6774 if the_lines [0 ][0 ] == " " :
6875 the_lines [0 ] = the_lines [0 ][1 :]
You can’t perform that action at this time.
0 commit comments