Class: Premailer
- Inherits:
-
Object
- Object
- Premailer
- Includes:
- CssParser, HtmlToPlainText, Warnings
- Defined in:
- lib/premailer/adapter.rb,
lib/premailer/version.rb,
lib/premailer/premailer.rb,
lib/premailer/cached_rule_set.rb,
lib/premailer/adapter/nokogiri.rb,
lib/premailer/adapter/nokogumbo.rb,
lib/premailer/adapter/nokogiri_fast.rb
Defined Under Namespace
Modules: Adapter, Warnings Classes: CachedRuleSet
Constant Summary collapse
- VERSION =
Premailer version.
'1.30.0'- CLIENT_SUPPORT_FILE =
File.dirname(__FILE__) + '/../../misc/client_support.yaml'
- RE_UNMERGABLE_SELECTORS =
Unmergable selectors regexp.
/(:(visited|active|hover|focus|after|before|selection|target|first-(line|letter))|^@)/i- RE_RESET_SELECTORS =
Reset selectors regexp.
/^(:\#outlook|body.*|\.ReadMsgBody|\.ExternalClass|img|\#backgroundTable)$/- HTML_ENTITIES =
list of HTMLEntities to fix source: http://stackoverflow.com/questions/2812781/how-to-convert-webpage-apostrophe-8217-to-ascii-39-in-ruby-1-
{ "’" => "'", "…" => "...", "‘" => "'", "‚" => ',', "‛" => "'", "“" => '"', "”" => '"', "‐" => '-', "–" => '-', "—" => '--', "―" => '--' }.freeze
- RELATED_ATTRIBUTES =
TODO:
too much repetition
TODO:background=""
list of CSS attributes that can be rendered as HTML 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' }, 'tr' => { 'text-align' => 'align', 'background-color' => 'bgcolor', '-premailer-height' => 'height' }, 'th' => { 'text-align' => 'align', 'background-color' => 'bgcolor', 'vertical-align' => 'valign', '-premailer-width' => 'width', '-premailer-height' => 'height' }, 'td' => { 'text-align' => 'align', 'background-color' => 'bgcolor', 'vertical-align' => 'valign', '-premailer-width' => 'width', '-premailer-height' => 'height' }, 'img' => { 'float' => 'align', '-premailer-width' => 'width', '-premailer-height' => 'height' } }.freeze
- WARN_LABEL =
Waning level names
['NONE', 'SAFE', 'POOR', 'RISKY'].freeze
Constants included from Warnings
Warnings::NONE, Warnings::POOR, Warnings::RISKY, Warnings::SAFE
Instance Attribute Summary collapse
-
#base_dir ⇒ String
readonly
base directory used to resolve links for local files.
-
#base_url ⇒ Object
readonly
base URL used to resolve links.
-
#doc ⇒ Object
readonly
source HTML document (Nokogiri/Nokogumbo).
-
#html_file ⇒ Object
readonly
URI of the HTML file used.
-
#processed_doc ⇒ Object
readonly
processed HTML document (Nokogiri/Nokogumbo).
-
#unmergable_rules ⇒ Object
readonly
unmergeable CSS rules to be preserved in the head (CssParser).
Class Method Summary collapse
- .canonicalize(uri) ⇒ Object
-
.local_data?(data) ⇒ Boolean
Test the passed variable to see if we are in local or remote mode.
- .media_query?(media_types) ⇒ Boolean
- .resolve_link(path, base_path) ⇒ Object
Instance Method Summary collapse
- #append_query_string(doc, queries) ⇒ Object
-
#check_client_support ⇒ Object
Check CLIENT_SUPPORT_FILE for any CSS warnings.
-
#cleanup! ⇒ Object
Free native Nokogiri/libxml2 memory held by this instance.
-
#convert_inline_links(doc, base_uri) ⇒ Object
Convert relative links to absolute links.
-
#initialize(html, options = {}) ⇒ Premailer
constructor
Create a new Premailer object.
- #local_uri?(uri) ⇒ Boolean deprecated Deprecated.
- #media_type_ok?(media_types) ⇒ Boolean
-
#warnings ⇒ Array(Hash)
CSS warnings.
-
#xhtml? ⇒ Boolean
Check for an XHTML doctype.
Methods included from HtmlToPlainText
Constructor Details
#initialize(html, options = {}) ⇒ Premailer
Create a new Premailer object.