title: How to convert html code to a string that replaces the newlines with \n and tabs with \t
body: <p>Is there an easy way to convert HTML code, that is structured in a certain way, to a single string (that can then be used in a Javascript variable). The new lines and tabs in the html code need to be converted to \n and \t so that the formatting can stay in tact.</p>
  
  <p>example HTML:</p>
  
  <pre><code>&lt;html&gt;
      &lt;head&gt;
           &lt;title&gt;Hello World&lt;/title&gt;
      &lt;/head&gt;
      &lt;body&gt;
          &lt;h1&gt;Title&lt;/h1&gt;
              &lt;h2&gt;Subtitle&lt;/h2&gt;
                  &lt;p&gt;Some text goes here&lt;/p&gt;
      &lt;/body&gt;
   &lt;/html&gt;
  </code></pre>
  
  <p>I've converted this manually to this:</p>
  
  <pre><code>&lt;html&gt;\n\n\t&lt;head&gt;\n\t\t &lt;title&gt;Hello World&lt;/title&gt;\n \t&lt;/head&gt;\n\n \t&lt;body&gt;\n \t\t&lt;h1&gt;Title&lt;/h1&gt;\n \t\t\t&lt;h2&gt;Subtitle&lt;/h2&gt;\n \t\t\t\t&lt;p&gt;Some text goes here&lt;/p&gt;\n \t&lt;/body&gt;\n\n &lt;/html&gt;\n
  </code></pre>
  
  <p>Is there an easy way to do this automatically? Because I need to convert larger chunks of HTML to this format. Thanks.</p>