Sha256: 2e7447502af480ea1c6dbc954470a116438e773fc60a131bc9eba5e2bc125c42

Contents?: true

Size: 548 Bytes

Versions: 1

Compression:

Stored size: 548 Bytes

Contents

module Feedjira
  class Preprocessor
    def initialize(xml)
      @xml = xml
    end

    def to_xml
      process_content
      doc.to_xml
    end

    private

    def process_content
      content_nodes.each do |node|
        node.content = raw_html(node) unless node.cdata?
      end
    end

    def content_nodes
      doc.search 'entry > content[type="xhtml"]'
    end

    def raw_html(node)
      CGI.unescape_html node.search('div').inner_html
    end

    def doc
      @doc ||= Nokogiri::XML(@xml).remove_namespaces!
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
feedjira-1.3.0 lib/feedjira/preprocessor.rb