Class Premailer
In: lib/premailer/adapter/nokogiri.rb
lib/premailer/adapter/hpricot.rb
lib/premailer/version.rb
lib/premailer/adapter.rb
lib/premailer/premailer.rb
Parent: Object

Methods

Included Modules

HtmlToPlainText CssParser Warnings

Classes and Modules

Module Premailer::Adapter
Module Premailer::Warnings

Constants

VERSION = '1.8.6'.freeze   Premailer version.
CLIENT_SUPPORT_FILE = File.dirname(__FILE__) + '/../../misc/client_support.yaml'
RE_UNMERGABLE_SELECTORS = /(\:(visited|active|hover|focus|after|before|selection|target|first\-(line|letter))|^\@)/i   Unmergable selectors regexp.
RE_RESET_SELECTORS = /^(\:\#outlook|body.*|\.ReadMsgBody|\.ExternalClass|img|\#backgroundTable)$/   Reset selectors regexp.
HTML_ENTITIES = { "’" => "'", "…" => "...", "‘" => "'", "‚" => ',', "‛" => "'", "“" => '"', "”" => '"', "‐" => '-', "–" => '-', "—" => '--', "―" => '--'   list of HTMLEntities to fix source: stackoverflow.com/questions/2812781/how-to-convert-webpage-apostrophe-8217-to-ascii-39-in-ruby-1-
RELATED_ATTRIBUTES = { 'h1' => {'text-align' => 'align'}, 'h2' => {'text-align' => 'align'}, 'h3' => {'text-align' => 'align'}, 'h4' => {'text-align' => 'align'}, 'h5' => {'text-align' => 'align'}, 'h6' => {'text-align' => 'align'}, 'p' => {'text-align' => 'align'}, 'div' => {'text-align' => 'align'}, 'blockquote' => {'text-align' => 'align'}, 'body' => {'background-color' => 'bgcolor'}, 'table' => { '-premailer-align' => 'align', 'background-color' => 'bgcolor', 'background-image' => 'background', '-premailer-width' => 'width', '-premailer-height' => 'height', '-premailer-cellpadding' => 'cellpadding', '-premailer-cellspacing' => 'cellspacing'   list of CSS attributes that can be rendered as HTML attributes

@todo too much repetition @todo background=""

WARN_LABEL = %w(NONE SAFE POOR RISKY)   Waning level names

Attributes

base_dir  [R]  base directory used to resolve links for local files @return [String] base directory
base_url  [R]  base URL used to resolve links
doc  [R]  source HTML document (Hpricot/Nokogiri)
html_file  [R]  URI of the HTML file used
processed_doc  [R]  processed HTML document (Hpricot/Nokogiri)
unmergable_rules  [R]  unmergeable CSS rules to be preserved in the head (CssParser)

Public Class methods

Test the passed variable to see if we are in local or remote mode.

IO objects return true, as do strings that look like URLs.

Create a new Premailer object.

@param html is the HTML data to process. It can be either an IO object, the URL of a

  remote file, a local path or a raw HTML string.  If passing an HTML string you
  must set the with_html_string option to true.

@param [Hash] options the options to handle html with. @option options [Fixnum] :line_length Line length used by to_plain_text. Default is 65. @option options [Fixnum] :warn_level What level of CSS compatibility warnings to show (see {Premailer::Warnings}). @option options [String] :link_query_string A string to append to every a href="" link. Do not include the initial ?. @option options [String] :base_url Used to calculate absolute URLs for local files. @option options [Array(String)] :css Manually specify CSS stylesheets. @option options [Boolean] :css_to_attributes Copy related CSS attributes into HTML attributes (e.g. background-color to bgcolor) @option options [String] :css_string Pass CSS as a string @option options [Boolean] :remove_ids Remove ID attributes whenever possible and convert IDs used as anchors to hashed to avoid collisions in webmail programs. Default is false. @option options [Boolean] :remove_classes Remove class attributes. Default is false. @option options [Boolean] :remove_comments Remove html comments. Default is false. @option options [Boolean] :remove_scripts Remove script elements. Default is true. @option options [Boolean] :reset_contenteditable Remove contenteditable attributes. Default is true. @option options [Boolean] :preserve_styles Whether to preserve any link rel=stylesheet and style elements. Default is false. @option options [Boolean] :preserve_reset Whether to preserve styles associated with the MailChimp reset code. Default is true. @option options [Boolean] :with_html_string Whether the html param should be treated as a raw string. Default is false. @option options [Boolean] :verbose Whether to print errors and warnings to $stderr. Default is false. @option options [Boolean] :include_link_tags Whether to include css from link rel=stylesheet tags. Default is true. @option options [Boolean] :include_style_tags Whether to include css from style tags. Default is true. @option options [String] :input_encoding Manually specify the source documents encoding. This is a good idea. Default is ASCII-8BIT. @option options [Boolean] :replace_html_entities Convert HTML entities to actual characters. Default is false. @option options [Boolean] :escape_url_attributes URL Escapes href, src, and background attributes on elements. Default is true. @option options [Symbol] :adapter Which HTML parser to use, either :nokogiri or :hpricot. Default is :hpricot. @option options [String] :output_encoding Output encoding option for Nokogiri adapter. Should be set to "US-ASCII" to output HTML entities instead of Unicode characters.

Public Instance methods

Check for an XHTML doctype

CSS warnings. @return [Array(Hash)] Array of warnings.

Protected Instance methods

[Validate]