Sha256: 37b3cf4abf489d1e3ed78734af19aa28948b14d3dafe6679cd4e3250cebc4e4e

Contents?: true

Size: 522 Bytes

Versions: 9

Compression:

Stored size: 522 Bytes

Contents

require 'premailer/adapter/nokogiri'

Premailer::Adapter::Nokogiri.module_eval do
  # Patch load_html method to fix character encoding issues.
  # Assume that actionmailer_inline_css will always be loading html from a UTF-8 string.
  def load_html(html)
    # Force UTF-8 encoding
    if RUBY_VERSION =~ /1.9/
      html = html.force_encoding('UTF-8').encode!
      doc = ::Nokogiri::HTML(html) {|c| c.recover }
    else
      doc = ::Nokogiri::HTML(html, nil, 'UTF-8') {|c| c.recover }
    end

    return doc
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
actionmailer_inline_css-1.6.0 lib/overrides/premailer/adapter/nokogiri.rb
actionmailer_inline_css-1.5.3 lib/overrides/premailer/adapter/nokogiri.rb
actionmailer_inline_css-1.5.2 lib/overrides/premailer/adapter/nokogiri.rb
actionmailer_inline_css-1.5.1 lib/overrides/premailer/adapter/nokogiri.rb
actionmailer_inline_css-1.5.0 lib/overrides/premailer/adapter/nokogiri.rb
actionmailer_inline_css-1.4.0 lib/overrides/premailer/adapter/nokogiri.rb
actionmailer_inline_css-1.3.1 lib/overrides/premailer/adapter/nokogiri.rb
actionmailer_inline_css-1.2.1 lib/overrides/premailer/adapter/nokogiri.rb
actionmailer_inline_css-1.2.0 lib/overrides/premailer/adapter/nokogiri.rb