Created
April 3, 2018 19:04
-
-
Save markddavidoff/33033ca0c86d0b89ce2403e539477953 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def wrap_text(text, wrap_point, line_break=u'<br />', line_prefix=u'',): | |
point = wrap_point | |
left_to_process = text | |
wrapped_str = u'' | |
while left_to_process: | |
wrapped_str += u"{line_prefix}{line_str}{line_break}".format( | |
line_prefix=line_prefix, | |
line_str=left_to_process[:wrap_point-len(line_prefix)], | |
line_break=line_break, | |
) | |
left_to_process = left_to_process[wrap_point-len(line_prefix):] | |
return wrapped_str |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment