title: Truncate text without truncating HTML
body: <p>This string has 78 characters with HTML and 39 characters without HTML:</p>
  
  <pre><code>&lt;p&gt;I really like the &lt;a href="http://google.com"&gt;Google&lt;/a&gt; search engine.&lt;/p&gt;
  </code></pre>
  
  <p>I want to truncate this string based on the non-HTML character count, so for example if I wanted to truncate the above string to 24 characters, the output would be:</p>
  
  <pre><code>I really like the &lt;a href="http://google.com"&gt;Google&lt;/a&gt;
  </code></pre>
  
  <p>The truncation did not take into account the html when determining the number of characters to cut off, it only considered the stripped count. However, it didn't leave open HTML tags.</p>