views:

29

answers:

1

I need to show the first 100 characters of an HTML text, which means, I have to pick the first 100 characters that are not tags and then close any open tags leaving a balanced HTML. Is there any library that can do it? Or is there any trivial way to do it that I am missing?

The text is originally written in Textile which can and does contain HTML, so I figured I am better off turning it to fully HTML first and then processing, but if something can do it at the Textile level, I'm happy too.

A: 

Have a look at Nokogiri

Kurt
I'm already familiar with Nokogiri, but I need more than just a parser to achieve this. Maybe Nokogiri can do it, but I haven't figured it out yet.
J. Pablo Fernández