lib/premailer/adapter/nokogiri.rb
# Load the HTML file and convert it into an Nokogiri document.
#
# @return [::Nokogiri::XML] a document.
Load the HTML file and convert it into an Nokogiri document.
Load the HTML file and convert it into an Nokogiri document .
def load_html(input) 
        thing = nil
        if @options[:with_html_string] or @options[:inline] or input.respond_to?(:read)
          thing = input
				elsif @is_local_file
          @base_dir = File.dirname(input)
          thing = File.open(input, 'r')
				else
          thing = open(input)
        end
        if thing.respond_to?(:read)
          thing = thing.read
        end
        return nil unless thing
        doc = nil
        if @options[:replace_html_entities] == true and thing.is_a?(String)
          if RUBY_VERSION =~ /1.9/
            html_entity_ruby_version = "1.9"
          elsif RUBY_VERSION =~ /1.8/
            html_entity_ruby_version = "1.8"
          end
          if html_entity_ruby_version
            HTML_ENTITIES[html_entity_ruby_version].map do |entity, replacement|
              thing.gsub! entity, replacement
            end
          end
        end
        if thing.is_a?(String) and RUBY_VERSION =~ /1.9/
          thing = thing.force_encoding(@options[:input_encoding]).encode!
          doc = ::Nokogiri::HTML(thing, nil, @options[:input_encoding]) {|c| c.recover }
        else
          default_encoding = RUBY_PLATFORM == 'java' ? nil : 'BINARY'
          doc = ::Nokogiri::HTML(thing, nil, @options[:input_encoding] || default_encoding) {|c| c.recover }
        end
        return doc
      end
def load_html ( input ) thing = nil if @options [ :with_html_string ] or @options [ :inline ] or input . respond_to? ( :read ) thing = input elsif @is_local_file @base_dir = File . dirname ( input ) thing = File . open ( input , 'r' ) else thing = open ( input ) end if thing . respond_to? ( :read ) thing = thing . read end return nil unless thing doc = nil if @options [ :replace_html_entities ] == true and thing . is_a? ( String ) if RUBY_VERSION =~ / 1.9 / html_entity_ruby_version = "1.9" elsif RUBY_VERSION =~ / 1.8 / html_entity_ruby_version = "1.8" end if html_entity_ruby_version HTML_ENTITIES [ html_entity_ruby_version ] . map do | entity , replacement | thing . gsub! entity , replacement end end end if thing . is_a? ( String ) and RUBY_VERSION =~ / 1.9 / thing = thing . force_encoding ( @options [ :input_encoding ] ) . encode! doc = :: Nokogiri :: HTML ( thing , nil , @options [ :input_encoding ] ) { | c | c . recover } else default_encoding = RUBY_PLATFORM == 'java' ? nil : 'BINARY' doc = :: Nokogiri :: HTML ( thing , nil , @options [ :input_encoding ] || default_encoding ) { | c | c . recover } end return doc end
Load the HTML file and convert it into an Nokogiri document.
Load the HTML file and convert it into an Nokogiri document .
# :nodoc: # TODO: duplicate options # Handle HTML entities # Default encoding is ASCII-8BIT (binary) per http://groups.google.com/group/nokogiri-talk/msg/0b81ef0dc180dc74 # However, we really don't want to hardcode this. ASCII-8BIG should be the default, but not the only option.
None
::Nokogiri::XML
input
<not_specific>