Skip to content

Instantly share code, notes, and snippets.

@markddavidoff
Created April 3, 2018 19:04
Show Gist options
  • Save markddavidoff/33033ca0c86d0b89ce2403e539477953 to your computer and use it in GitHub Desktop.
Save markddavidoff/33033ca0c86d0b89ce2403e539477953 to your computer and use it in GitHub Desktop.
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