title: Parsing plain text Markdown from a ContentEditable div
body: <p>I know there are other questions on editable divs, but I couldn't find one specific to the Markdown-related issue I have.</p>
  
  <p>User will be typing inside a ContentEditable div. And he may choose to do any number of Markdown-related things like code blocks, headers, and whatever.</p>
  
  <p>I am having issues extracting the source properly and storing it into my database to be displayed again later by a standard Markdown parser. I have tried two ways:</p>
  
  <ol>
  <li><code>$('.content').text()</code></li>
  </ol>
  
  <p>In this method, the problem is that all the line breaks are stripped out and of course that is not okay.</p>
  
  <ol start="2">
  <li><code>$('.content').html()</code></li>
  </ol>
  
  <p>In this method, I can get the line breaks working fine by using regex to replace <code>&lt;br\&gt;</code> with <code>\n</code> before inserting into database. But the browser also wraps things like <code>## Heading Here</code> with divs, like this: <code>&lt;div&gt;## Heading Here&lt;/div&gt;</code>. This is problematic for me because when I go to display this afterwards, I don't get the proper Markdown formatting.</p>
  
  <p>What's the best (most simple and reliable) way to solve this problem as of 2015?</p>
  
  <p><strong>EDIT:</strong> Found a potential solution here: <a href="http://www.davidtong.me/innerhtml-innertext-textcontent-html-and-text/" rel="nofollow">http://www.davidtong.me/innerhtml-innertext-textcontent-html-and-text/</a></p>