title: Is there an HTML safe truncate method in Rails?
body: <p>I have a string of HTML in Rails. I'd like to truncate the string after a certain number of characters not including the HTML markup. Also, if the split happens to fall in the middle of an opening and closing tag, I'd like to close the open tag/s. For example;</p>
  
  <pre><code>html = "123&lt;a href='#'&gt;456&lt;/a&gt;7890"
  truncate_markup(html, :length =&gt; 5) --&gt; "123&lt;a href='#'&gt;45&lt;/a&gt;"
  </code></pre>