title: Parsing a nested tag, moving it outside of the parent, and changing its type using Nokogiri
body: <p>I have HTML coming from an API that I want to clean up and format it. </p>
  
  <p>I'm trying to get any <code>&lt;strong&gt;</code> tags that are the first element inside a <code>&lt;p&gt;</code> tag, and change it to be the parent of the <code>&lt;p&gt;</code> tag, and convert the <code>&lt;p&gt;</code> tag to <code>&lt;h4&gt;</code>.</p>
  
  <p>For example:</p>
  
  <pre><code>&lt;p&gt;&lt;strong&gt;This is what I want to pull out to an h4 tag.&lt;/strong&gt;Here's the rest of the paragraph.&lt;/p&gt;
  </code></pre>
  
  <p>becomes:</p>
  
  <pre><code>&lt;h4&gt;This is what I want to pull out to an h4 tag.&lt;/h4&gt;&lt;p&gt;Here's the rest of the paragraph.&lt;/p&gt;
  </code></pre>
  
  <p>EDIT: Apologies for the nature of the question being too 'please write this for me'. I posted the solution I came up with below. I just had to take the time to really learn how Nokogiri works, but it is quite powerful and it seems like you can do almost anything with it.</p>