html_inline_css 0.1.1 → 0.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f0fb35bde96b92eabde2a58574784873f3c1cf14
4
- data.tar.gz: bd6aebd893df04b0dc94110db383ee284d2f37ab
3
+ metadata.gz: 67bc2dfe2bbdfb63d8dfe20699d9191ed5800763
4
+ data.tar.gz: f324638b4722c7fa6da597b3c94096bc328c791c
5
5
  SHA512:
6
- metadata.gz: a5cc2135d18baa8cbba0f2e8f04713a83ecb93ee6e6d6bc6bef3d1439893d79bc7950b8d24c3482955cec8065fa6ea652552c9ed590e3422314b0291932e273c
7
- data.tar.gz: 593cc742e4707f8cdc161dc5b3bf915eda460f3868963f2bfd9ecd337ee4dbd1cd3c7244d8a4457c976dd4ef7dae3699e6f757d64fbab76613162fa0a5a5795e
6
+ metadata.gz: 45109e3180550e85db4a4a9aaf245683426143308c58b27816bf7195f6fe4939302d20912687939c38991b5d33dec1a6970c350cdbe06d63e14d6b8a6e5847d9
7
+ data.tar.gz: 17b50d0684315e7601211af7d57ef3244df56d688d1f7564bcd694695645d773838225cda0ba6bc7d5c0c39d9f1ec2291814772ef4c7c95419235450dc279948
@@ -1,397 +1,399 @@
1
1
  require "html_inline_css/version"
2
2
  require "nokogiri"
3
3
 
4
- class InlineCSS
5
-
6
- def inline_css(html)
7
- @html_tags = ["div","span","b","a","i","abbr","acronym","address","applet","area","article","aside","bdi","big","blockquote","caption","center","cite","code","col","colgroup","datalist","dd","del","details","dfn","dialog","dir","dl","dt","em","footer","form","frame","frameset","h1","h2","h3","h4","h5","h6","hr","iframe","img","input","ins","kbd","keygen","label","legend","li","link","main","map","mark","menu","menuitem","meter","nav","object","ol","optgroup","option","output","p","param","pre","progress","q","rp","rt","ruby","s","samp","section","select","small","source","strike","strong","sub","summary","sup","table","tbody","td","textarea","tfoot","th","thead","time","tr","track","tt","u","ul","var","wbr"]
8
- @classes = Array.new
9
- @ids = Array.new
10
- @html_without_skeleton = html.gsub(/<style>(.*?)\n\t\t<\/style>|<style>(.*?)<\/style>|<html>|<\/html>|<head>|<\/head>|<body>|<\/body>|<script>|<\/script>/,"")
11
- @doc = Nokogiri::HTML::DocumentFragment.parse(html)
12
- @doc_to = Nokogiri::HTML::DocumentFragment.parse(@html_without_skeleton)
13
- get_all_class_and_ids
14
- add_style_tag_to_html(@doc_to)
15
- inline_css_from_style_tag(@doc)
16
- return @doc_to.to_html
17
- end
4
+ module InlineCssString
5
+ class CSS
6
+
7
+ def self.inline_css(html)
8
+ @html_tags = ["div","span","b","a","i","abbr","acronym","address","applet","area","article","aside","bdi","big","blockquote","caption","center","cite","code","col","colgroup","datalist","dd","del","details","dfn","dialog","dir","dl","dt","em","footer","form","frame","frameset","h1","h2","h3","h4","h5","h6","hr","iframe","img","input","ins","kbd","keygen","label","legend","li","link","main","map","mark","menu","menuitem","meter","nav","object","ol","optgroup","option","output","p","param","pre","progress","q","rp","rt","ruby","s","samp","section","select","small","source","strike","strong","sub","summary","sup","table","tbody","td","textarea","tfoot","th","thead","time","tr","track","tt","u","ul","var","wbr"]
9
+ @classes = Array.new
10
+ @ids = Array.new
11
+ @html_without_skeleton = html.gsub(/<style>(.*?)\n\t\t<\/style>|<style>(.*?)<\/style>|<html>|<\/html>|<head>|<\/head>|<body>|<\/body>|<script>|<\/script>/,"")
12
+ @doc = Nokogiri::HTML::DocumentFragment.parse(html)
13
+ @doc_to = Nokogiri::HTML::DocumentFragment.parse(@html_without_skeleton)
14
+ get_all_class_and_ids
15
+ add_style_tag_to_html(@doc_to)
16
+ inline_css_from_style_tag(@doc)
17
+ return @doc_to.to_html
18
+ end
18
19
 
19
- def get_all_class_and_ids
20
- @html_tags.each do |tag|
21
- @doc_to.css("#{tag}").each do |y|
22
- unless y.nil?
23
- if @classes.empty?
24
- @classes << y["class"].to_s;
25
- else
26
- @classes.each do |css_class|; unless css_class == y["class"] || y["class"].nil?; @classes << y["class"].to_s; break; end; end;
27
- end
28
- if @ids.empty?
29
- @ids << y["id"].to_s;
30
- else
31
- @ids.each do |css_id|; unless css_id == y["id"] || y["id"].nil?; @ids << y["id"].to_s; break; end; end;
20
+ def get_all_class_and_ids
21
+ @html_tags.each do |tag|
22
+ @doc_to.css("#{tag}").each do |y|
23
+ unless y.nil?
24
+ if @classes.empty?
25
+ @classes << y["class"].to_s;
26
+ else
27
+ @classes.each do |css_class|; unless css_class == y["class"] || y["class"].nil?; @classes << y["class"].to_s; break; end; end;
28
+ end
29
+ if @ids.empty?
30
+ @ids << y["id"].to_s;
31
+ else
32
+ @ids.each do |css_id|; unless css_id == y["id"] || y["id"].nil?; @ids << y["id"].to_s; break; end; end;
33
+ end
32
34
  end
33
35
  end
34
36
  end
35
37
  end
36
- end
37
38
 
38
- def add_style_tag_to_html(html)
39
- @html_tags.each do |tag|
40
- html.css("#{tag}").each do |x|
41
- unless x.nil?
42
- unless x.to_s.match(/<#{Regexp.escape(tag)}\s(.*?)style=('|")(.*?)('|")(.*?)>/)
43
- x['style'] = ''
39
+ def add_style_tag_to_html(html)
40
+ @html_tags.each do |tag|
41
+ html.css("#{tag}").each do |x|
42
+ unless x.nil?
43
+ unless x.to_s.match(/<#{Regexp.escape(tag)}\s(.*?)style=('|")(.*?)('|")(.*?)>/)
44
+ x['style'] = ''
45
+ end
44
46
  end
45
47
  end
46
48
  end
47
49
  end
48
- end
49
50
 
50
- def add_style(tag, arr)
51
- unless arr.nil?;
52
- @doc_to.css("#{tag}").each do |y|
53
- unless y.nil?
54
- y.to_s.scan(/style="([^"]*)"|style='([^"]*)'/).flatten.select{ |i| !i.nil?; unless i.nil?; y['style'] = "#{arr}#{i}" end }
51
+ def add_style(tag, arr)
52
+ unless arr.nil?;
53
+ @doc_to.css("#{tag}").each do |y|
54
+ unless y.nil?
55
+ y.to_s.scan(/style="([^"]*)"|style='([^"]*)'/).flatten.select{ |i| !i.nil?; unless i.nil?; y['style'] = "#{arr}#{i}" end }
56
+ end
55
57
  end
56
58
  end
57
59
  end
58
- end
59
60
 
60
- def add_style_by_id_or_class(id_or_class_name, arr, id_or_class)
61
- unless arr.nil?;
62
- if id_or_class == "class"
63
- @html_tags.each do |tag|
64
- @doc_to.xpath("#{tag}[@class = '#{id_or_class_name}']").each do |y|
65
- unless y.nil?
66
- y.to_s.scan(/style="([^"]*)"|style='([^"]*)'/).flatten.select{ |i| !i.nil?; unless i.nil?; y['style'] = "#{arr}#{i}" end }
61
+ def add_style_by_id_or_class(id_or_class_name, arr, id_or_class)
62
+ unless arr.nil?;
63
+ if id_or_class == "class"
64
+ @html_tags.each do |tag|
65
+ @doc_to.xpath("#{tag}[@class = '#{id_or_class_name}']").each do |y|
66
+ unless y.nil?
67
+ y.to_s.scan(/style="([^"]*)"|style='([^"]*)'/).flatten.select{ |i| !i.nil?; unless i.nil?; y['style'] = "#{arr}#{i}" end }
68
+ end
67
69
  end
68
70
  end
69
- end
70
- else
71
- @html_tags.each do |tag|
72
- @doc_to.xpath("#{tag}[@class = '#{id_or_class_name}']").each do |y|
73
- unless y.nil?
74
- y.to_s.scan(/style="([^"]*)"|style='([^"]*)'/).flatten.select{ |i| !i.nil?; unless i.nil?; y['style'] = "#{arr}#{i}" end }
71
+ else
72
+ @html_tags.each do |tag|
73
+ @doc_to.xpath("#{tag}[@class = '#{id_or_class_name}']").each do |y|
74
+ unless y.nil?
75
+ y.to_s.scan(/style="([^"]*)"|style='([^"]*)'/).flatten.select{ |i| !i.nil?; unless i.nil?; y['style'] = "#{arr}#{i}" end }
76
+ end
75
77
  end
76
78
  end
77
79
  end
78
80
  end
79
81
  end
80
- end
81
82
 
82
- def inline_css_from_style_tag(html)
83
-
84
- style_tags = html.search('style').map { |n| n.inner_text }
83
+ def inline_css_from_style_tag(html)
84
+
85
+ style_tags = html.search('style').map { |n| n.inner_text }
85
86
 
86
- style_tags.each do |tag|
87
+ style_tags.each do |tag|
87
88
 
88
- # DIV
89
- tag.scan(/div(.*?){(.*?)}/).flatten.select{ |x| !x.nil?; add_style("div", x) }
89
+ # DIV
90
+ tag.scan(/div(.*?){(.*?)}/).flatten.select{ |x| !x.nil?; add_style("div", x) }
90
91
 
91
- # PARAGRAPH
92
- tag.scan(/p\s{(.*?)}|p{(.*?)}/).flatten.select{ |x| !x.nil?; add_style("p", x) }
92
+ # PARAGRAPH
93
+ tag.scan(/p\s{(.*?)}|p{(.*?)}/).flatten.select{ |x| !x.nil?; add_style("p", x) }
93
94
 
94
- # BOLD
95
- tag.scan(/b\s{(.*?)}|b{(.*?)}/).flatten.select{ |x| !x.nil?; add_style("b", x) }
95
+ # BOLD
96
+ tag.scan(/b\s{(.*?)}|b{(.*?)}/).flatten.select{ |x| !x.nil?; add_style("b", x) }
96
97
 
97
- # ITALIC
98
- tag.scan(/i{(.*?)}|i\s{(.*?)}/).flatten.select{ |x| !x.nil?; add_style("i", x) }
98
+ # ITALIC
99
+ tag.scan(/i{(.*?)}|i\s{(.*?)}/).flatten.select{ |x| !x.nil?; add_style("i", x) }
99
100
 
100
- # SPAN
101
- tag.scan(/span(.*?){(.*?)}/).flatten.select{ |x| !x.nil?; add_style("span", x) }
101
+ # SPAN
102
+ tag.scan(/span(.*?){(.*?)}/).flatten.select{ |x| !x.nil?; add_style("span", x) }
102
103
 
103
- # H1
104
- tag.scan(/h1(.*?){(.*?)}/).flatten.select{ |x| !x.nil?; add_style("h1", x) }
104
+ # H1
105
+ tag.scan(/h1(.*?){(.*?)}/).flatten.select{ |x| !x.nil?; add_style("h1", x) }
105
106
 
106
- # H2
107
- tag.scan(/h2(.*?){(.*?)}/).flatten.select{ |x| !x.nil?; add_style("h2", x) }
107
+ # H2
108
+ tag.scan(/h2(.*?){(.*?)}/).flatten.select{ |x| !x.nil?; add_style("h2", x) }
108
109
 
109
- # H3
110
- tag.scan(/h3(.*?){(.*?)}/).flatten.select{ |x| !x.nil?; add_style("h3", x) }
110
+ # H3
111
+ tag.scan(/h3(.*?){(.*?)}/).flatten.select{ |x| !x.nil?; add_style("h3", x) }
111
112
 
112
- # H4
113
- tag.scan(/h4(.*?){(.*?)}/).flatten.select{ |x| !x.nil?; add_style("h4", x) }
113
+ # H4
114
+ tag.scan(/h4(.*?){(.*?)}/).flatten.select{ |x| !x.nil?; add_style("h4", x) }
114
115
 
115
- # H5
116
- tag.scan(/h5(.*?){(.*?)}/).flatten.select{ |x| !x.nil?; add_style("h5", x) }
116
+ # H5
117
+ tag.scan(/h5(.*?){(.*?)}/).flatten.select{ |x| !x.nil?; add_style("h5", x) }
117
118
 
118
- # H6
119
- tag.scan(/h6(.*?){(.*?)}/).flatten.select{ |x| !x.nil?; add_style("h6", x) }
119
+ # H6
120
+ tag.scan(/h6(.*?){(.*?)}/).flatten.select{ |x| !x.nil?; add_style("h6", x) }
120
121
 
121
- # A
122
- tag.scan(/a(.*?){(.*?)}/).flatten.select{ |x| !x.nil?; add_style("a", x) }
122
+ # A
123
+ tag.scan(/a(.*?){(.*?)}/).flatten.select{ |x| !x.nil?; add_style("a", x) }
123
124
 
124
- # ABBR
125
- tag.scan(/abbr(.*?){(.*?)}/).flatten.select{ |x| !x.nil?; add_style("abbr", x) }
125
+ # ABBR
126
+ tag.scan(/abbr(.*?){(.*?)}/).flatten.select{ |x| !x.nil?; add_style("abbr", x) }
126
127
 
127
- # ACRONYM
128
- tag.scan(/acronym(.*?){(.*?)}/).flatten.select{ |x| !x.nil?; add_style("acronym", x) }
128
+ # ACRONYM
129
+ tag.scan(/acronym(.*?){(.*?)}/).flatten.select{ |x| !x.nil?; add_style("acronym", x) }
129
130
 
130
- # ADDRESS
131
- tag.scan(/address(.*?){(.*?)}/).flatten.select{ |x| !x.nil?; add_style("address", x) }
131
+ # ADDRESS
132
+ tag.scan(/address(.*?){(.*?)}/).flatten.select{ |x| !x.nil?; add_style("address", x) }
132
133
 
133
- # APPLET
134
- tag.scan(/applet(.*?){(.*?)}/).flatten.select{ |x| !x.nil?; add_style("applet", x) }
134
+ # APPLET
135
+ tag.scan(/applet(.*?){(.*?)}/).flatten.select{ |x| !x.nil?; add_style("applet", x) }
135
136
 
136
- # AREA
137
- tag.scan(/area(.*?){(.*?)}/).flatten.select{ |x| !x.nil?; add_style("area", x) }
137
+ # AREA
138
+ tag.scan(/area(.*?){(.*?)}/).flatten.select{ |x| !x.nil?; add_style("area", x) }
138
139
 
139
- # ARTICLE
140
- tag.scan(/article(.*?){(.*?)}/).flatten.select{ |x| !x.nil?; add_style("article", x) }
140
+ # ARTICLE
141
+ tag.scan(/article(.*?){(.*?)}/).flatten.select{ |x| !x.nil?; add_style("article", x) }
141
142
 
142
- # ASIDE
143
- tag.scan(/aside(.*?){(.*?)}/).flatten.select{ |x| !x.nil?; add_style("aside", x) }
143
+ # ASIDE
144
+ tag.scan(/aside(.*?){(.*?)}/).flatten.select{ |x| !x.nil?; add_style("aside", x) }
144
145
 
145
- # BDI
146
- tag.scan(/bdi(.*?){(.*?)}/).flatten.select{ |x| !x.nil?; add_style("bdi", x) }
146
+ # BDI
147
+ tag.scan(/bdi(.*?){(.*?)}/).flatten.select{ |x| !x.nil?; add_style("bdi", x) }
147
148
 
148
- # BIG
149
- tag.scan(/big(.*?){(.*?)}/).flatten.select{ |x| !x.nil?; add_style("big", x) }
149
+ # BIG
150
+ tag.scan(/big(.*?){(.*?)}/).flatten.select{ |x| !x.nil?; add_style("big", x) }
150
151
 
151
- # BLOCKQUOTE
152
- tag.scan(/blockquote(.*?){(.*?)}/).flatten.select{ |x| !x.nil?; add_style("blockquote", x) }
152
+ # BLOCKQUOTE
153
+ tag.scan(/blockquote(.*?){(.*?)}/).flatten.select{ |x| !x.nil?; add_style("blockquote", x) }
153
154
 
154
- # CAPTION
155
- tag.scan(/caption(.*?){(.*?)}/).flatten.select{ |x| !x.nil?; add_style("caption", x) }
155
+ # CAPTION
156
+ tag.scan(/caption(.*?){(.*?)}/).flatten.select{ |x| !x.nil?; add_style("caption", x) }
156
157
 
157
- # CENTER
158
- tag.scan(/center(.*?){(.*?)}/).flatten.select{ |x| !x.nil?; add_style("center", x) }
158
+ # CENTER
159
+ tag.scan(/center(.*?){(.*?)}/).flatten.select{ |x| !x.nil?; add_style("center", x) }
159
160
 
160
- # CITE
161
- tag.scan(/cite(.*?){(.*?)}/).flatten.select{ |x| !x.nil?; add_style("cite", x) }
161
+ # CITE
162
+ tag.scan(/cite(.*?){(.*?)}/).flatten.select{ |x| !x.nil?; add_style("cite", x) }
162
163
 
163
- # CODE
164
- tag.scan(/code(.*?){(.*?)}/).flatten.select{ |x| !x.nil?; add_style("code", x) }
164
+ # CODE
165
+ tag.scan(/code(.*?){(.*?)}/).flatten.select{ |x| !x.nil?; add_style("code", x) }
165
166
 
166
- # COL
167
- tag.scan(/col(.*?){(.*?)}/).flatten.select{ |x| !x.nil?; add_style("col", x) }
167
+ # COL
168
+ tag.scan(/col(.*?){(.*?)}/).flatten.select{ |x| !x.nil?; add_style("col", x) }
168
169
 
169
- # COLGROUP
170
- tag.scan(/colgroup(.*?){(.*?)}/).flatten.select{ |x| !x.nil?; add_style("colgroup", x) }
170
+ # COLGROUP
171
+ tag.scan(/colgroup(.*?){(.*?)}/).flatten.select{ |x| !x.nil?; add_style("colgroup", x) }
171
172
 
172
- # DATALIST
173
- tag.scan(/datalist(.*?){(.*?)}/).flatten.select{ |x| !x.nil?; add_style("datalist", x) }
173
+ # DATALIST
174
+ tag.scan(/datalist(.*?){(.*?)}/).flatten.select{ |x| !x.nil?; add_style("datalist", x) }
174
175
 
175
- # DD
176
- tag.scan(/dd(.*?){(.*?)}/).flatten.select{ |x| !x.nil?; add_style("dd", x) }
176
+ # DD
177
+ tag.scan(/dd(.*?){(.*?)}/).flatten.select{ |x| !x.nil?; add_style("dd", x) }
177
178
 
178
- # DEL
179
- tag.scan(/del(.*?){(.*?)}/).flatten.select{ |x| !x.nil?; add_style("del", x) }
179
+ # DEL
180
+ tag.scan(/del(.*?){(.*?)}/).flatten.select{ |x| !x.nil?; add_style("del", x) }
180
181
 
181
- # details
182
- tag.scan(/details(.*?){(.*?)}/).flatten.select{ |x| !x.nil?; add_style("details", x) }
182
+ # details
183
+ tag.scan(/details(.*?){(.*?)}/).flatten.select{ |x| !x.nil?; add_style("details", x) }
183
184
 
184
- # DFN
185
- tag.scan(/dfn(.*?){(.*?)}/).flatten.select{ |x| !x.nil?; add_style("dfn", x) }
185
+ # DFN
186
+ tag.scan(/dfn(.*?){(.*?)}/).flatten.select{ |x| !x.nil?; add_style("dfn", x) }
186
187
 
187
- # DIALOG
188
- tag.scan(/dialog(.*?){(.*?)}/).flatten.select{ |x| !x.nil?; add_style("dialog", x) }
188
+ # DIALOG
189
+ tag.scan(/dialog(.*?){(.*?)}/).flatten.select{ |x| !x.nil?; add_style("dialog", x) }
189
190
 
190
- # DIR
191
- tag.scan(/dir(.*?){(.*?)}/).flatten.select{ |x| !x.nil?; add_style("dir", x) }
191
+ # DIR
192
+ tag.scan(/dir(.*?){(.*?)}/).flatten.select{ |x| !x.nil?; add_style("dir", x) }
192
193
 
193
- # DL
194
- tag.scan(/dl(.*?){(.*?)}/).flatten.select{ |x| !x.nil?; add_style("dl", x) }
194
+ # DL
195
+ tag.scan(/dl(.*?){(.*?)}/).flatten.select{ |x| !x.nil?; add_style("dl", x) }
195
196
 
196
- # DT
197
- tag.scan(/dt(.*?){(.*?)}/).flatten.select{ |x| !x.nil?; add_style("dt", x) }
197
+ # DT
198
+ tag.scan(/dt(.*?){(.*?)}/).flatten.select{ |x| !x.nil?; add_style("dt", x) }
198
199
 
199
- # EM
200
- tag.scan(/em(.*?){(.*?)}/).flatten.select{ |x| !x.nil?; add_style("em", x) }
200
+ # EM
201
+ tag.scan(/em(.*?){(.*?)}/).flatten.select{ |x| !x.nil?; add_style("em", x) }
201
202
 
202
- # FOOTER
203
- tag.scan(/footer(.*?){(.*?)}/).flatten.select{ |x| !x.nil?; add_style("footer", x) }
203
+ # FOOTER
204
+ tag.scan(/footer(.*?){(.*?)}/).flatten.select{ |x| !x.nil?; add_style("footer", x) }
204
205
 
205
- # FORM
206
- tag.scan(/form(.*?){(.*?)}/).flatten.select{ |x| !x.nil?; add_style("form", x) }
206
+ # FORM
207
+ tag.scan(/form(.*?){(.*?)}/).flatten.select{ |x| !x.nil?; add_style("form", x) }
207
208
 
208
- # FRAME
209
- tag.scan(/frame(.*?){(.*?)}/).flatten.select{ |x| !x.nil?; add_style("frame", x) }
209
+ # FRAME
210
+ tag.scan(/frame(.*?){(.*?)}/).flatten.select{ |x| !x.nil?; add_style("frame", x) }
210
211
 
211
- # FRAMESET
212
- tag.scan(/frameset(.*?){(.*?)}/).flatten.select{ |x| !x.nil?; add_style("frameset", x) }
212
+ # FRAMESET
213
+ tag.scan(/frameset(.*?){(.*?)}/).flatten.select{ |x| !x.nil?; add_style("frameset", x) }
213
214
 
214
- # HR
215
- tag.scan(/hr(.*?){(.*?)}/).flatten.select{ |x| !x.nil?; add_style("hr", x) }
215
+ # HR
216
+ tag.scan(/hr(.*?){(.*?)}/).flatten.select{ |x| !x.nil?; add_style("hr", x) }
216
217
 
217
- # IFRAME
218
- tag.scan(/iframe(.*?){(.*?)}/).flatten.select{ |x| !x.nil?; add_style("iframe", x) }
218
+ # IFRAME
219
+ tag.scan(/iframe(.*?){(.*?)}/).flatten.select{ |x| !x.nil?; add_style("iframe", x) }
219
220
 
220
- # IMG
221
- tag.scan(/img(.*?){(.*?)}/).flatten.select{ |x| !x.nil?; add_style("img", x) }
221
+ # IMG
222
+ tag.scan(/img(.*?){(.*?)}/).flatten.select{ |x| !x.nil?; add_style("img", x) }
222
223
 
223
- # INPUT
224
- tag.scan(/input(.*?){(.*?)}/).flatten.select{ |x| !x.nil?; add_style("input", x) }
224
+ # INPUT
225
+ tag.scan(/input(.*?){(.*?)}/).flatten.select{ |x| !x.nil?; add_style("input", x) }
225
226
 
226
- # INS
227
- tag.scan(/ins(.*?){(.*?)}/).flatten.select{ |x| !x.nil?; add_style("ins", x) }
227
+ # INS
228
+ tag.scan(/ins(.*?){(.*?)}/).flatten.select{ |x| !x.nil?; add_style("ins", x) }
228
229
 
229
- # KBD
230
- tag.scan(/kbd(.*?){(.*?)}/).flatten.select{ |x| !x.nil?; add_style("kbd", x) }
230
+ # KBD
231
+ tag.scan(/kbd(.*?){(.*?)}/).flatten.select{ |x| !x.nil?; add_style("kbd", x) }
231
232
 
232
- # KEYGEN
233
- tag.scan(/keygen(.*?){(.*?)}/).flatten.select{ |x| !x.nil?; add_style("keygen", x) }
233
+ # KEYGEN
234
+ tag.scan(/keygen(.*?){(.*?)}/).flatten.select{ |x| !x.nil?; add_style("keygen", x) }
234
235
 
235
- # LABEL
236
- tag.scan(/label(.*?){(.*?)}/).flatten.select{ |x| !x.nil?; add_style("label", x) }
236
+ # LABEL
237
+ tag.scan(/label(.*?){(.*?)}/).flatten.select{ |x| !x.nil?; add_style("label", x) }
237
238
 
238
- # LEGEND
239
- tag.scan(/legend(.*?){(.*?)}/).flatten.select{ |x| !x.nil?; add_style("legend", x) }
239
+ # LEGEND
240
+ tag.scan(/legend(.*?){(.*?)}/).flatten.select{ |x| !x.nil?; add_style("legend", x) }
240
241
 
241
- # LI
242
- tag.scan(/li(.*?){(.*?)}/).flatten.select{ |x| !x.nil?; add_style("li", x) }
242
+ # LI
243
+ tag.scan(/li(.*?){(.*?)}/).flatten.select{ |x| !x.nil?; add_style("li", x) }
243
244
 
244
- # LINK
245
- tag.scan(/link(.*?){(.*?)}/).flatten.select{ |x| !x.nil?; add_style("link", x) }
245
+ # LINK
246
+ tag.scan(/link(.*?){(.*?)}/).flatten.select{ |x| !x.nil?; add_style("link", x) }
246
247
 
247
- # MAIN
248
- tag.scan(/main(.*?){(.*?)}/).flatten.select{ |x| !x.nil?; add_style("main", x) }
248
+ # MAIN
249
+ tag.scan(/main(.*?){(.*?)}/).flatten.select{ |x| !x.nil?; add_style("main", x) }
249
250
 
250
- # MAP
251
- tag.scan(/map(.*?){(.*?)}/).flatten.select{ |x| !x.nil?; add_style("map", x) }
251
+ # MAP
252
+ tag.scan(/map(.*?){(.*?)}/).flatten.select{ |x| !x.nil?; add_style("map", x) }
252
253
 
253
- # MARK
254
- tag.scan(/mark(.*?){(.*?)}/).flatten.select{ |x| !x.nil?; add_style("mark", x) }
254
+ # MARK
255
+ tag.scan(/mark(.*?){(.*?)}/).flatten.select{ |x| !x.nil?; add_style("mark", x) }
255
256
 
256
- # MENU
257
- tag.scan(/menu(.*?){(.*?)}/).flatten.select{ |x| !x.nil?; add_style("menu", x) }
257
+ # MENU
258
+ tag.scan(/menu(.*?){(.*?)}/).flatten.select{ |x| !x.nil?; add_style("menu", x) }
258
259
 
259
- # MENUITEM
260
- tag.scan(/menuitem(.*?){(.*?)}/).flatten.select{ |x| !x.nil?; add_style("menuitem", x) }
260
+ # MENUITEM
261
+ tag.scan(/menuitem(.*?){(.*?)}/).flatten.select{ |x| !x.nil?; add_style("menuitem", x) }
261
262
 
262
- # METER
263
- tag.scan(/meter(.*?){(.*?)}/).flatten.select{ |x| !x.nil?; add_style("meter", x) }
263
+ # METER
264
+ tag.scan(/meter(.*?){(.*?)}/).flatten.select{ |x| !x.nil?; add_style("meter", x) }
264
265
 
265
- # NAV
266
- tag.scan(/nav(.*?){(.*?)}/).flatten.select{ |x| !x.nil?; add_style("nav", x) }
266
+ # NAV
267
+ tag.scan(/nav(.*?){(.*?)}/).flatten.select{ |x| !x.nil?; add_style("nav", x) }
267
268
 
268
- # OBJECT
269
- tag.scan(/object(.*?){(.*?)}/).flatten.select{ |x| !x.nil?; add_style("object", x) }
269
+ # OBJECT
270
+ tag.scan(/object(.*?){(.*?)}/).flatten.select{ |x| !x.nil?; add_style("object", x) }
270
271
 
271
- # OL
272
- tag.scan(/ol(.*?){(.*?)}/).flatten.select{ |x| !x.nil?; add_style("ol", x) }
272
+ # OL
273
+ tag.scan(/ol(.*?){(.*?)}/).flatten.select{ |x| !x.nil?; add_style("ol", x) }
273
274
 
274
- # OPTGROUP
275
- tag.scan(/optgroup(.*?){(.*?)}/).flatten.select{ |x| !x.nil?; add_style("optgroup", x) }
275
+ # OPTGROUP
276
+ tag.scan(/optgroup(.*?){(.*?)}/).flatten.select{ |x| !x.nil?; add_style("optgroup", x) }
276
277
 
277
- # OPTION
278
- tag.scan(/option(.*?){(.*?)}/).flatten.select{ |x| !x.nil?; add_style("option", x) }
278
+ # OPTION
279
+ tag.scan(/option(.*?){(.*?)}/).flatten.select{ |x| !x.nil?; add_style("option", x) }
279
280
 
280
- # OUTPUT
281
- tag.scan(/output(.*?){(.*?)}/).flatten.select{ |x| !x.nil?; add_style("output", x) }
281
+ # OUTPUT
282
+ tag.scan(/output(.*?){(.*?)}/).flatten.select{ |x| !x.nil?; add_style("output", x) }
282
283
 
283
- # PARAM
284
- tag.scan(/param(.*?){(.*?)}/).flatten.select{ |x| !x.nil?; add_style("param", x) }
284
+ # PARAM
285
+ tag.scan(/param(.*?){(.*?)}/).flatten.select{ |x| !x.nil?; add_style("param", x) }
285
286
 
286
- # PRE
287
- tag.scan(/pre(.*?){(.*?)}/).flatten.select{ |x| !x.nil?; add_style("pre", x) }
287
+ # PRE
288
+ tag.scan(/pre(.*?){(.*?)}/).flatten.select{ |x| !x.nil?; add_style("pre", x) }
288
289
 
289
- # PROGRESS
290
- tag.scan(/progress(.*?){(.*?)}/).flatten.select{ |x| !x.nil?; add_style("progress", x) }
290
+ # PROGRESS
291
+ tag.scan(/progress(.*?){(.*?)}/).flatten.select{ |x| !x.nil?; add_style("progress", x) }
291
292
 
292
- # Q
293
- tag.scan(/q{(.*?)}|q\s{(.*?)}/).flatten.select{ |x| !x.nil?; add_style("q", x) }
293
+ # Q
294
+ tag.scan(/q{(.*?)}|q\s{(.*?)}/).flatten.select{ |x| !x.nil?; add_style("q", x) }
294
295
 
295
- # RP
296
- tag.scan(/rp(.*?){(.*?)}/).flatten.select{ |x| !x.nil?; add_style("rp", x) }
296
+ # RP
297
+ tag.scan(/rp(.*?){(.*?)}/).flatten.select{ |x| !x.nil?; add_style("rp", x) }
297
298
 
298
- # RT
299
- tag.scan(/rt(.*?){(.*?)}/).flatten.select{ |x| !x.nil?; add_style("rt", x) }
299
+ # RT
300
+ tag.scan(/rt(.*?){(.*?)}/).flatten.select{ |x| !x.nil?; add_style("rt", x) }
300
301
 
301
- # RUBY
302
- tag.scan(/ruby(.*?){(.*?)}/).flatten.select{ |x| !x.nil?; add_style("ruby", x) }
302
+ # RUBY
303
+ tag.scan(/ruby(.*?){(.*?)}/).flatten.select{ |x| !x.nil?; add_style("ruby", x) }
303
304
 
304
- # S
305
- tag.scan(/s{(.*?)}|s\s{(.*?)}/).flatten.select{ |x| !x.nil?; add_style("ruby", x) }
305
+ # S
306
+ tag.scan(/s{(.*?)}|s\s{(.*?)}/).flatten.select{ |x| !x.nil?; add_style("ruby", x) }
306
307
 
307
- # SAMP
308
- tag.scan(/samp(.*?){(.*?)}/).flatten.select{ |x| !x.nil?; add_style("samp", x) }
308
+ # SAMP
309
+ tag.scan(/samp(.*?){(.*?)}/).flatten.select{ |x| !x.nil?; add_style("samp", x) }
309
310
 
310
- # SECTION
311
- tag.scan(/section(.*?){(.*?)}/).flatten.select{ |x| !x.nil?; add_style("section", x) }
311
+ # SECTION
312
+ tag.scan(/section(.*?){(.*?)}/).flatten.select{ |x| !x.nil?; add_style("section", x) }
312
313
 
313
- # SELECT
314
- tag.scan(/select(.*?){(.*?)}/).flatten.select{ |x| !x.nil?; add_style("select", x) }
314
+ # SELECT
315
+ tag.scan(/select(.*?){(.*?)}/).flatten.select{ |x| !x.nil?; add_style("select", x) }
315
316
 
316
- # SMALL
317
- tag.scan(/small(.*?){(.*?)}/).flatten.select{ |x| !x.nil?; add_style("small", x) }
317
+ # SMALL
318
+ tag.scan(/small(.*?){(.*?)}/).flatten.select{ |x| !x.nil?; add_style("small", x) }
318
319
 
319
- # SOURCE
320
- tag.scan(/source(.*?){(.*?)}/).flatten.select{ |x| !x.nil?; add_style("source", x) }
320
+ # SOURCE
321
+ tag.scan(/source(.*?){(.*?)}/).flatten.select{ |x| !x.nil?; add_style("source", x) }
321
322
 
322
- # STRIKE
323
- tag.scan(/strike(.*?){(.*?)}/).flatten.select{ |x| !x.nil?; add_style("strike", x) }
323
+ # STRIKE
324
+ tag.scan(/strike(.*?){(.*?)}/).flatten.select{ |x| !x.nil?; add_style("strike", x) }
324
325
 
325
- # STRONG
326
- tag.scan(/strong(.*?){(.*?)}/).flatten.select{ |x| !x.nil?; add_style("strong", x) }
326
+ # STRONG
327
+ tag.scan(/strong(.*?){(.*?)}/).flatten.select{ |x| !x.nil?; add_style("strong", x) }
327
328
 
328
- # SUB
329
- tag.scan(/sub(.*?){(.*?)}/).flatten.select{ |x| !x.nil?; add_style("sub", x) }
329
+ # SUB
330
+ tag.scan(/sub(.*?){(.*?)}/).flatten.select{ |x| !x.nil?; add_style("sub", x) }
330
331
 
331
- # SUMMARY
332
- tag.scan(/summary(.*?){(.*?)}/).flatten.select{ |x| !x.nil?; add_style("summary", x) }
332
+ # SUMMARY
333
+ tag.scan(/summary(.*?){(.*?)}/).flatten.select{ |x| !x.nil?; add_style("summary", x) }
333
334
 
334
- # SUP
335
- tag.scan(/sup(.*?){(.*?)}/).flatten.select{ |x| !x.nil?; add_style("sup", x) }
335
+ # SUP
336
+ tag.scan(/sup(.*?){(.*?)}/).flatten.select{ |x| !x.nil?; add_style("sup", x) }
336
337
 
337
- # TABLE
338
- tag.scan(/table(.*?){(.*?)}/).flatten.select{ |x| !x.nil?; add_style("table", x) }
338
+ # TABLE
339
+ tag.scan(/table(.*?){(.*?)}/).flatten.select{ |x| !x.nil?; add_style("table", x) }
339
340
 
340
- # TBODY
341
- tag.scan(/tbody(.*?){(.*?)}/).flatten.select{ |x| !x.nil?; add_style("tbody", x) }
341
+ # TBODY
342
+ tag.scan(/tbody(.*?){(.*?)}/).flatten.select{ |x| !x.nil?; add_style("tbody", x) }
342
343
 
343
- # TD
344
- tag.scan(/td(.*?){(.*?)}/).flatten.select{ |x| !x.nil?; add_style("td", x) }
344
+ # TD
345
+ tag.scan(/td(.*?){(.*?)}/).flatten.select{ |x| !x.nil?; add_style("td", x) }
345
346
 
346
- # TEXTAREA
347
- tag.scan(/textarea(.*?){(.*?)}/).flatten.select{ |x| !x.nil?; add_style("textarea", x) }
347
+ # TEXTAREA
348
+ tag.scan(/textarea(.*?){(.*?)}/).flatten.select{ |x| !x.nil?; add_style("textarea", x) }
348
349
 
349
- # TFOOT
350
- tag.scan(/tfoot(.*?){(.*?)}/).flatten.select{ |x| !x.nil?; add_style("tfoot", x) }
350
+ # TFOOT
351
+ tag.scan(/tfoot(.*?){(.*?)}/).flatten.select{ |x| !x.nil?; add_style("tfoot", x) }
351
352
 
352
- # TH
353
- tag.scan(/th(.*?){(.*?)}/).flatten.select{ |x| !x.nil?; add_style("th", x) }
353
+ # TH
354
+ tag.scan(/th(.*?){(.*?)}/).flatten.select{ |x| !x.nil?; add_style("th", x) }
354
355
 
355
- # THEAD
356
- tag.scan(/thead(.*?){(.*?)}/).flatten.select{ |x| !x.nil?; add_style("thead", x) }
356
+ # THEAD
357
+ tag.scan(/thead(.*?){(.*?)}/).flatten.select{ |x| !x.nil?; add_style("thead", x) }
357
358
 
358
- # TIME
359
- tag.scan(/time(.*?){(.*?)}/).flatten.select{ |x| !x.nil?; add_style("time", x) }
359
+ # TIME
360
+ tag.scan(/time(.*?){(.*?)}/).flatten.select{ |x| !x.nil?; add_style("time", x) }
360
361
 
361
- # TR
362
- tag.scan(/tr(.*?){(.*?)}/).flatten.select{ |x| !x.nil?; add_style("tr", x) }
362
+ # TR
363
+ tag.scan(/tr(.*?){(.*?)}/).flatten.select{ |x| !x.nil?; add_style("tr", x) }
363
364
 
364
- # TRACK
365
- tag.scan(/track(.*?){(.*?)}/).flatten.select{ |x| !x.nil?; add_style("track", x) }
365
+ # TRACK
366
+ tag.scan(/track(.*?){(.*?)}/).flatten.select{ |x| !x.nil?; add_style("track", x) }
366
367
 
367
- # TT
368
- tag.scan(/tt(.*?){(.*?)}/).flatten.select{ |x| !x.nil?; add_style("tt", x) }
368
+ # TT
369
+ tag.scan(/tt(.*?){(.*?)}/).flatten.select{ |x| !x.nil?; add_style("tt", x) }
369
370
 
370
- # U
371
- tag.scan(/u{(.*?)}|u\s{(.*?)}/).flatten.select{ |x| !x.nil?; add_style("u", x) }
371
+ # U
372
+ tag.scan(/u{(.*?)}|u\s{(.*?)}/).flatten.select{ |x| !x.nil?; add_style("u", x) }
372
373
 
373
- # UL
374
- tag.scan(/ul(.*?){(.*?)}/).flatten.select{ |x| !x.nil?; add_style("ul", x) }
374
+ # UL
375
+ tag.scan(/ul(.*?){(.*?)}/).flatten.select{ |x| !x.nil?; add_style("ul", x) }
375
376
 
376
- # VAR
377
- tag.scan(/var(.*?){(.*?)}/).flatten.select{ |x| !x.nil?; add_style("var", x) }
377
+ # VAR
378
+ tag.scan(/var(.*?){(.*?)}/).flatten.select{ |x| !x.nil?; add_style("var", x) }
378
379
 
379
- # WBR
380
- tag.scan(/wbr(.*?){(.*?)}/).flatten.select{ |x| !x.nil?; add_style("wbr", x) }
380
+ # WBR
381
+ tag.scan(/wbr(.*?){(.*?)}/).flatten.select{ |x| !x.nil?; add_style("wbr", x) }
381
382
 
382
- # CLASS
383
- @classes.each do |css_class|
384
- regex = /\.#{Regexp.escape(css_class)}\s{(.*?)}|\.#{Regexp.escape(css_class)}{(.*?)}/
385
- tag.scan(regex).flatten.select{ |x| !x.nil?; add_style_by_id_or_class(css_class, x, 'class'); }
386
- end
383
+ # CLASS
384
+ @classes.each do |css_class|
385
+ regex = /\.#{Regexp.escape(css_class)}\s{(.*?)}|\.#{Regexp.escape(css_class)}{(.*?)}/
386
+ tag.scan(regex).flatten.select{ |x| !x.nil?; add_style_by_id_or_class(css_class, x, 'class'); }
387
+ end
387
388
 
388
- # ID
389
- @ids.each do |css_id|
390
- regex = /\##{Regexp.escape(css_id)}\s{(.*?)}|\##{Regexp.escape(css_id)}{(.*?)}/
391
- tag.scan(regex).flatten.select{ |x| !x.nil?; add_style_by_id_or_class(css_id, x, 'id') }
392
- end
389
+ # ID
390
+ @ids.each do |css_id|
391
+ regex = /\##{Regexp.escape(css_id)}\s{(.*?)}|\##{Regexp.escape(css_id)}{(.*?)}/
392
+ tag.scan(regex).flatten.select{ |x| !x.nil?; add_style_by_id_or_class(css_id, x, 'id') }
393
+ end
393
394
 
395
+ end
394
396
  end
395
- end
396
397
 
397
- end
398
+ end
399
+ end
@@ -1,3 +1,3 @@
1
1
  module HtmlInlineCss
2
- VERSION = "0.1.1"
2
+ VERSION = "0.1.2"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: html_inline_css
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nicolai Berg Andersen