Sha256: d7dc94c20e210b3ac3af5ef609b59708e180c6ea8f9f3ba32cf81b41146ec415

Contents?: true

Size: 771 Bytes

Versions: 3

Compression:

Stored size: 771 Bytes

Contents

require 'nokogiri'

class NokoTest
  webpage = <<~END_PAGE
    <html>
      <body>
        <p>Marvin the Martian, from Warner Bros, was <a href="https://kidadl.com/quotes/marvin-the-martian-quotes-from-the-looney-tunes-beloved-character">often angry</a>.</p>
        <p>Being disintegrated makes me very angry! Very angry indeed!</p>
        <p>I’m not angry. Just terribly, terribly hurt.</p>
        <p>You make me very angry, very angry.</p>
        <p>Flux to blow Mars into subatomic space dust make me very angry.</p>
      </body>
    </html>
  END_PAGE

  html = Nokogiri.HTML(webpage)
  html.css('p').each do |node|
    # This strips any HTML tags from node.content:
    node.content = node.content.gsub('angry', 'happy')
  end
  puts "\n\nHTML:\n#{html}"
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
jekyll_plugin_template-0.3.1 spec/nokogiri_test.rb
jekyll_plugin_template-0.3.0 spec/nokogiri_test.rb
jekyll_plugin_template-0.2.0 spec/nokogiri_test.rb