I've just started using RedCloth as part of a simple wiki feature in my ruby on rails app.
I'd like to be able to display a word count next to wiki pages in the index.
Given the textile pulled from the database as input, how should I go about getting an accurate word count as output?
The most obvious solution would be to simply split by /\s+/
and remove all the known textile tokens such as p.
or #
from the resulting array.
But I'm wondering if there's a more elegant (less tedious) solution, such as a feature of RedCloth or a fast and ready way of removing the markup from the RedCloth html output which would leave just whitespace separated words.