C
Chris Gehlker
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.
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.