Skip to content

Instantly share code, notes, and snippets.

@NickWoodhams
Created January 12, 2017 18:13
Show Gist options
  • Save NickWoodhams/5001075527688f7ab428780f25bf39ac to your computer and use it in GitHub Desktop.
Save NickWoodhams/5001075527688f7ab428780f25bf39ac to your computer and use it in GitHub Desktop.
Swap line break characters for div elements you can style. Useful for Displaying Textarea input values.
def nl2lb(value):
return value.replace('\n', '<div class="line-break"></div>')
# Or even simpler
def nl2br(value):
return value.replace('\n', '<br>')
.line-break {
margin-bottom: 11px;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment