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
We had this need in zendone.com. The problem was that the existing solutions were very slow when truncating long HTML documents (MBs) into shorter ones (KBs). I ended up coding a library based in Nokogiri called truncato. The library includes some benchmarks comparing its performance with other libs.