Sha256: c11685cb4d32c7935ec077a9f7664bb38adf0b7cf8340838e0220afa2cc0b4b3
Contents?: true
Size: 946 Bytes
Versions: 2
Compression:
Stored size: 946 Bytes
Contents
require 'open-uri' require 'rubygems' require 'nokogiri' require 'css_inliner/version' require 'css_inliner/csspool' require 'css_inliner/inliner' module CSSInliner class << self # @param [Nokogiri::XML::Document, String] html # @param [String] basedir Base directory or URI to traverse relative URI for images # @param [String] element Element name to be returned. # Returns whole document when nil # @param [String] format Format to output, html or xhtml # @return [String] HTML source def process(html, basedir = '.', element = nil, format = 'html') doc = html.instance_of?(Nokogiri::XML::Document) ? html : Nokogiri.HTML(html) doc = Inliner.new(doc, basedir).inline doc = doc.css(element)[0] if element case format when 'xhtml' doc.to_xhtml when 'html' doc.to_html when 'xml' doc.to_xml else doc.to_s end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
css_inliner-0.3.2 | lib/css_inliner.rb |
css_inliner-0.3.1 | lib/css_inliner.rb |