From: Chris Gehlker Date: 2006-08-16T13:04:46+09:00 Subject: Re: A simple Hpricot text setter On Aug 14, 2006, at 9:29 AM, why the lucky stiff wrote: > Okay, yeah, you'll need the latest Hpricot (0.4.43): > > gem install hpricot --source code.whytheluckystiff.net > > Also, don't forget to remove `require_gem 'hpricot'` and use, instead, > `require 'hpricot'`. > > _why You seem to be making great progress with Hpricot, committing changes every day. Yep, 'require_gem' no longer works. Just using 'require' seems better. I don't know that I communicated my idea behind adding a set method for Hpricot::Text. There are times when one wants to scan an potentially change everything that's *not* markup. The markup should be left unchanged or modified only in trivial ways such as changing the order of attribute declarations. Hpricott::Traverse#traverse_text is great for finding as the stuff that's *not* markup, the pcdata, in an HTML file. I just added a method to change that data. You suggested using inner_html= but the only way I can see that working is to parse the tree looking for those elements which only have Hpricot::Text children and then using inner_html= on them. But that would involve essentially recreating Hpricott::Traverse#traverse_text to find such elements although the common code could mostly be factored out. -- And those who were seen dancing were thought to be insane by those who could not hear the music. -Friedrich Wilhelm Nietzsche, philosopher (1844-1900)