Method: Premailer#initialize

Defined in:
lib/premailer/premailer.rb

#initialize(html, options = {}) ⇒ Premailer

Create a new Premailer object.

Parameters:

  • 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.

  • options (Hash) (defaults to: {}) —

    the options to handle html with.

Options Hash (options):

  • :line_length (Fixnum) —

    Line length used by to_plain_text. Default is 65.

  • :warn_level (Fixnum) —

    What level of CSS compatibility warnings to show (see Warnings, default is Warnings::SAFE).

  • :link_query_string (String) —

    A string to append to every a href="" link. Do not include the initial ?.

  • :base_url (String) —

    Used to calculate absolute URLs for local files.

  • :css (Array(String)) —

    Manually specify CSS stylesheets.

  • :css_to_attributes (Boolean) —

    Copy related CSS attributes into HTML attributes (e.g. background-color to bgcolor). Default is true.

  • :preserve_style_attribute (Boolean) —

    Preserve original style attribute

  • :css_string (String) —

    Pass CSS as a string

  • :rgb_to_hex_attributes (Boolean) —

    Convert RBG to Hex colors. Default is false.

  • :remove_ids (Boolean) —

    Remove ID attributes whenever possible and convert IDs used as anchors to hashed to avoid collisions in webmail programs. Default is false.

  • :remove_classes (Boolean) —

    Remove class attributes. Default is false.

  • :remove_comments (Boolean) —

    Remove html comments. Default is false.

  • :remove_scripts (Boolean) —

    Remove script elements. Default is true.

  • :reset_contenteditable (Boolean) —

    Remove contenteditable attributes. Default is true.

  • :preserve_styles (Boolean) —

    Whether to preserve any link rel=stylesheet and style elements. Default is false.

  • :preserve_reset (Boolean) —

    Whether to preserve styles associated with the MailChimp reset code. Default is true.

  • :with_html_string (Boolean) —

    Whether the html param should be treated as a raw string. Default is false.

  • :verbose (Boolean) —

    Whether to print errors and warnings to $stderr. Default is false.

  • :io_exceptions (Boolean) —

    Throws exceptions on I/O errors. Default is false.

  • :rule_set_exceptions (Boolean) —

    Throws exceptions on invalid values in CSS Parser rule sets. Default is true.

  • :include_link_tags (Boolean) —

    Whether to include css from link rel=stylesheet tags. Default is true.

  • :include_style_tags (Boolean) —

    Whether to include css from style tags. Default is true.

  • :input_encoding (String) —

    Manually specify the source documents encoding. This is a good idea. Default is ASCII-8BIT.

  • :replace_html_entities (Boolean) —

    Convert HTML entities to actual characters. Default is false.

  • :escape_url_attributes (Boolean) —

    URL Escapes href, src, and background attributes on elements. Default is true.

  • :adapter (Symbol) —

    Which HTML parser to use, :nokogiri, :nokogiri_fast or :nokogumbo. Default is :nokogiri.

  • :output_encoding (String) —

    Output encoding option for Nokogiri adapter. Should be set to "US-ASCII" to output HTML entities instead of Unicode characters.

  • :create_shorthands (Boolean) —

    Combine several properties into a shorthand one, e.g. font: style weight size. Default is true.

  • :html_fragment (Boolean) —

    Handle HTML fragment without any HTML content wrappers. Default is false.

  • :drop_unmergeable_css_rules (Boolean) —

    Do not include unmergeable css rules in a