Skip to content

Instantly share code, notes, and snippets.

@kikito
Forked from kares/simpleFormat.js
Last active December 16, 2015 03:39
Show Gist options
  • Save kikito/5371091 to your computer and use it in GitHub Desktop.
Save kikito/5371091 to your computer and use it in GitHub Desktop.
function simpleFormat(str) {
return '<p>' +
str.replace(/\r\n?/, "\n")
.replace(/\n\n+/g, '</p>\n\n<p>')
.replace(/([^\n]\n)(?=[^\n])/g, '$1<br/>') +
'</p>';
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment