Last active
November 27, 2017 21:40
-
-
Save kmaida/7a96c55020be05df039613b39f81920a to your computer and use it in GitHub Desktop.
Convert newlines to markup (e.g., from a textarea)
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
newlinesToMarkup(text) { | |
const withPTags = '<p>' + text.replace(/\n([ \t]*\n)+/g, '</p><p>').replace('\n', '<br>') + '</p>'; | |
return withPTags; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment