Last active
June 25, 2019 09:43
-
-
Save MattMS/e35f27c878620dce9acbda32b033fdf1 to your computer and use it in GitHub Desktop.
Text to HTML conversion.
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
var split_p_and_br = s => s.trim().split(/\n\n/).map(s => s.replace(/\n/g, '<br />')) | |
var split_p = s => s.trim().split(/\n\n/).map(s => s.replace(/\n/g, ' ')) | |
var join_p = p => p.join('</p><p>') | |
var fin = t => `<p>${t}</p>` | |
var a = ` | |
hello | |
multi | |
line | |
string | |
oh | |
yeah | |
` | |
var with_breaks = fin(join_p(split_p_and_br(a))) | |
var without_breaks = fin(join_p(split_p(a))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment