title: Convert new line to correct Javascript value
body: <p>I have a series of data that I want to put inside an array in a javascript. I use Wordpress as a cms, and my data looks like this (the content of the post): </p>
  
  <pre><code>line1
  line2
  line3
  </code></pre>
  
  <p>However when i try to seek data from the post I see this code in javascript for let's say 3 posts:</p>
  
  <pre><code>var locations=['line1
  line2
  line3','line1
  line2
  line3','line1
  line2
  line3'];
  </code></pre>
  
  <p>I receive this error when I look in the console: <strong><em>Uncaught SyntaxError: Unexpected token ILLEGAL</em></strong>. I have searched here a lot of answers but I did not succeed into breaking a leg with it. However I had a look in the HTML tab of the content there is no <code>&lt;br/&gt;</code>, so the new line is not html code. </p>
  
  <p>I also tried to escape special characters in php like this, but it pops out the same error:</p>
  
  <pre><code>echo '\''.htmlspecialchars (get_the_content()).'\',';
  </code></pre>
  
  <p>However, if the content is in one line, like 'some text' it appears to run ok.</p>
  
  <p>Any ideas?</p>
  
  <p>Thank you!</p>