title: Nokogiri replace inner text with <span>ed words
body: <p>Here's an example HTML fragment:</p>
  
  <pre><code>&lt;p class="stanza"&gt;Thus grew the tale of Wonderland:&lt;br/&gt;
    Thus slowly, one by one,&lt;br/&gt;
    Its quaint events were hammered out -&lt;br/&gt;
    And now the tale is done,&lt;br/&gt;
    And home we steer, a merry crew,&lt;br/&gt;
    Beneath the setting sun.&lt;br/&gt;&lt;/p&gt;
  </code></pre>
  
  <p>I need to surround each word with a <code>&lt;span id="w0"&gt;Thus &lt;/span&gt;</code> like this:</p>
  
  <pre><code>&lt;span id='w1'&gt;Anon,&lt;/span&gt; &lt;span id='w2'&gt;to&lt;/span&gt; &lt;span id='w3'&gt;sudden&lt;/span&gt; 
  &lt;span id='w4'&gt;silence&lt;/span&gt; &lt;span id='w5'&gt;won,&lt;/span&gt; ....
  </code></pre>
  
  <p>I written this which creates the new fragment.  How do I replace/swap the new for old?</p>
  
  <pre><code>def callchildren(n)
    n.children.each do |n| # call recursively until arrive at a node w/o children
      callchildren(n)
    end
    if n.node_type == 3 &amp;&amp; n.to_s.strip.empty? != true 
      new_node = ""
      n.to_s.split.each { |w|
        new_node = new_node + "&lt;span id='w#{$word_number}'&gt;#{w}&lt;/span&gt; "
        $word_number += 1
      }  
      # puts new_node 
      # HELP? How do I get new_node swapped in?
    end
  end
  </code></pre>