Sha256: 568448e847e2ab27c797584ac5636c74ab0bb48a28534303847236359c8a9e32

Contents?: true

Size: 834 Bytes

Versions: 3

Compression:

Stored size: 834 Bytes

Contents

module Loofah
  module HTML # :nodoc:
    #
    #  Subclass of Nokogiri::HTML::DocumentFragment.
    #
    #  See Loofah::ScrubBehavior and Loofah::TextBehavior for additional methods.
    #
    class DocumentFragment < Nokogiri::HTML::DocumentFragment
      include Loofah::TextBehavior

      class << self
        #
        #  Overridden Nokogiri::HTML::DocumentFragment
        #  constructor. Applications should use Loofah.fragment to
        #  parse a fragment.
        #
        def parse tags
          self.new(Loofah::HTML::Document.new, tags)
        end
      end

      #
      #  Returns the HTML markup contained by the fragment
      #
      def to_s
        serialize_root.children.to_s
      end
      alias :serialize :to_s

      def serialize_root
        at_xpath("./body") || self
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
loofah-1.0.0 lib/loofah/html/document_fragment.rb
loofah-1.0.0.beta.1 lib/loofah/html/document_fragment.rb
loofah-0.4.7 lib/loofah/html/document_fragment.rb