Class: Roadie::Inliner
- Inherits:
-
Object
- Object
- Roadie::Inliner
- Defined in:
- lib/roadie/inliner.rb
Overview
This class is the core of Roadie as it does all the actual work. You just give it the CSS rules, the HTML and the url_options for rewriting URLs and let it go on doing all the heavy lifting and building.
Constant Summary collapse
- CSS_URL_REGEXP =
Regexp matching all the url() declarations in CSS
It matches without any quotes and with both single and double quotes inside the parenthesis. There’s much room for improvement, of course.
%r{ url\( (["']?) ( [^(]* # Text leading up to before opening parens (?:\([^)]*\))* # Texts containing parens pairs [^(]+ # Texts without parens - required ) \1 # Closing quote \) }x
Instance Method Summary collapse
-
#execute ⇒ String
Start the inlining and return the final HTML output.
-
#initialize(css, html, url_options) ⇒ Inliner
constructor
Initialize a new Inliner with the given CSS, HTML and url_options.
Constructor Details
#initialize(css, html, url_options) ⇒ Inliner
Initialize a new Inliner with the given CSS, HTML and url_options.
29 30 31 32 33 34 |
# File 'lib/roadie/inliner.rb', line 29 def initialize(css, html, ) @css = css @inline_css = [] @html = html @url_options = end |
Instance Method Details
#execute ⇒ String
Start the inlining and return the final HTML output
38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/roadie/inliner.rb', line 38 def execute adjust_html do |document| @document = document add_missing_structure extract_link_elements extract_inline_style_elements inline_css_rules make_image_urls_absolute make_style_urls_absolute @document = nil end end |