If anyone is trying to use Hpricot to clean up the actual content of
a site while leaving the markup alone, theymight find the following
tiny method useful:
class Hpricot::Text
Adds a simple Hpricot method to change
the text embedded in an HTML document
Example of use:
body.traverse_text do |text|
text_out = text.to_s
manupulate text_out
text.set(text_out)
end
def set(string)
@content = string
self.raw_string = string
end
end
The trick is to set both @content in Hpricot::Text and @raw_string in
it’s parent.
The folly of mistaking a paradox for a discovery, a metaphor for a
proof, a torrent of verbiage for a spring of capital truths, and
oneself for an oracle, is inborn in us.
-Paul Valery, poet and philosopher (1871-1945)