-
Notifications
You must be signed in to change notification settings - Fork 6
/
converter.rb
executable file
·41 lines (40 loc) · 1.43 KB
/
converter.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#!/usr/bin/ruby
require 'rubygems'
begin
gem 'premailer'
require 'premailer'
require 'getopt/long'
opt = Getopt::Long.getopts(
['--markup', Getopt::REQUIRED],
['--css_to_attributes', Getopt::BOOLEAN],
['--include_link_tags', Getopt::BOOLEAN],
['--include_style_tags', Getopt::BOOLEAN],
['--input_encoding', Getopt::OPTIONAL],
['--preserve_reset', Getopt::BOOLEAN],
['--preserve_styles', Getopt::BOOLEAN],
['--remove_classes', Getopt::BOOLEAN],
['--remove_comments', Getopt::BOOLEAN],
['--remove_ids', Getopt::BOOLEAN],
['--remove_scripts', Getopt::BOOLEAN],
['--replace_html_entities', Getopt::BOOLEAN],
['--with_html_string', Getopt::BOOLEAN]
)
premailer = Premailer.new(
opt['markup'].dup,
:css_to_attributes => opt['css_to_attributes'],
:include_link_tags => opt['include_link_tags'],
:include_style_tags => opt['include_style_tags'],
:input_encoding => opt['input_encoding'],
:preserve_reset => opt['preserve_reset'],
:preserve_styles => opt['preserve_styles'],
:remove_classes => opt['remove_classes'],
:remove_comments => opt['remove_comments'],
:remove_ids => opt['remove_ids'],
:remove_scripts => opt['remove_scripts'],
:replace_html_entities => opt['replace_html_entities'],
:with_html_string => opt['with_html_string']
)
puts premailer.to_inline_css
rescue Gem::LoadError
raise 'Premailer not loaded'
end