Skip to content

Instantly share code, notes, and snippets.

@ptone
Created May 11, 2012 20:31
Show Gist options
  • Save ptone/2662223 to your computer and use it in GitHub Desktop.
Save ptone/2662223 to your computer and use it in GitHub Desktop.
injects non-printing chars into long strings so that they will wrap properly in a fixed width div
def softwrap(desc):
noprint = '​'
return ' '.join(
[noprint.join(list(x)) if (len(x) > 20) else x for x in desc.split()])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment