title: Converting new lines to paragraph/br HTML tags, can this be a single regex?
body: <p>An app I am working on has the user enter content in plaintext that will later be displayed as HTML. To make the user's content display as nicely as possible, we transform the content as follows:</p>
  
  <ul>
  <li><p>Any blocks of text delimited by two or more new line characters are wrapped in &lt;p&gt; tags. The new line characters (and any whitespace in-between) are stripped out.</p></li>
  <li><p>Any single new line characters (along with surrounding whitespace) are replaced by a &lt;br /&gt; tag.</p></li>
  </ul>
  
  <p>I'm currently achieving this by putting the the text through two regex replacements but was wondering if it could possibly be consolidated to one. Here's what I have right now (JavaScript):</p>
  
  <pre><code>// content holds the text to process
  content = '&lt;p&gt;' + content.replace(/\n([ \t]*\n)+/g, '&lt;/p&gt;&lt;p&gt;')
                   .replace(/\n/g, '&lt;br /&gt;') + '&lt;/p&gt;';
  </code></pre>