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 +4 -4
- data/lib/html_inline_css.rb +269 -267
- data/lib/html_inline_css/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 67bc2dfe2bbdfb63d8dfe20699d9191ed5800763
|
4
|
+
data.tar.gz: f324638b4722c7fa6da597b3c94096bc328c791c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 45109e3180550e85db4a4a9aaf245683426143308c58b27816bf7195f6fe4939302d20912687939c38991b5d33dec1a6970c350cdbe06d63e14d6b8a6e5847d9
|
7
|
+
data.tar.gz: 17b50d0684315e7601211af7d57ef3244df56d688d1f7564bcd694695645d773838225cda0ba6bc7d5c0c39d9f1ec2291814772ef4c7c95419235450dc279948
|
data/lib/html_inline_css.rb
CHANGED
@@ -1,397 +1,399 @@
|
|
1
1
|
require "html_inline_css/version"
|
2
2
|
require "nokogiri"
|
3
3
|
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
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
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
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
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
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
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
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
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
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
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
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
|
-
|
83
|
-
|
84
|
-
|
83
|
+
def inline_css_from_style_tag(html)
|
84
|
+
|
85
|
+
style_tags = html.search('style').map { |n| n.inner_text }
|
85
86
|
|
86
|
-
|
87
|
+
style_tags.each do |tag|
|
87
88
|
|
88
|
-
|
89
|
-
|
89
|
+
# DIV
|
90
|
+
tag.scan(/div(.*?){(.*?)}/).flatten.select{ |x| !x.nil?; add_style("div", x) }
|
90
91
|
|
91
|
-
|
92
|
-
|
92
|
+
# PARAGRAPH
|
93
|
+
tag.scan(/p\s{(.*?)}|p{(.*?)}/).flatten.select{ |x| !x.nil?; add_style("p", x) }
|
93
94
|
|
94
|
-
|
95
|
-
|
95
|
+
# BOLD
|
96
|
+
tag.scan(/b\s{(.*?)}|b{(.*?)}/).flatten.select{ |x| !x.nil?; add_style("b", x) }
|
96
97
|
|
97
|
-
|
98
|
-
|
98
|
+
# ITALIC
|
99
|
+
tag.scan(/i{(.*?)}|i\s{(.*?)}/).flatten.select{ |x| !x.nil?; add_style("i", x) }
|
99
100
|
|
100
|
-
|
101
|
-
|
101
|
+
# SPAN
|
102
|
+
tag.scan(/span(.*?){(.*?)}/).flatten.select{ |x| !x.nil?; add_style("span", x) }
|
102
103
|
|
103
|
-
|
104
|
-
|
104
|
+
# H1
|
105
|
+
tag.scan(/h1(.*?){(.*?)}/).flatten.select{ |x| !x.nil?; add_style("h1", x) }
|
105
106
|
|
106
|
-
|
107
|
-
|
107
|
+
# H2
|
108
|
+
tag.scan(/h2(.*?){(.*?)}/).flatten.select{ |x| !x.nil?; add_style("h2", x) }
|
108
109
|
|
109
|
-
|
110
|
-
|
110
|
+
# H3
|
111
|
+
tag.scan(/h3(.*?){(.*?)}/).flatten.select{ |x| !x.nil?; add_style("h3", x) }
|
111
112
|
|
112
|
-
|
113
|
-
|
113
|
+
# H4
|
114
|
+
tag.scan(/h4(.*?){(.*?)}/).flatten.select{ |x| !x.nil?; add_style("h4", x) }
|
114
115
|
|
115
|
-
|
116
|
-
|
116
|
+
# H5
|
117
|
+
tag.scan(/h5(.*?){(.*?)}/).flatten.select{ |x| !x.nil?; add_style("h5", x) }
|
117
118
|
|
118
|
-
|
119
|
-
|
119
|
+
# H6
|
120
|
+
tag.scan(/h6(.*?){(.*?)}/).flatten.select{ |x| !x.nil?; add_style("h6", x) }
|
120
121
|
|
121
|
-
|
122
|
-
|
122
|
+
# A
|
123
|
+
tag.scan(/a(.*?){(.*?)}/).flatten.select{ |x| !x.nil?; add_style("a", x) }
|
123
124
|
|
124
|
-
|
125
|
-
|
125
|
+
# ABBR
|
126
|
+
tag.scan(/abbr(.*?){(.*?)}/).flatten.select{ |x| !x.nil?; add_style("abbr", x) }
|
126
127
|
|
127
|
-
|
128
|
-
|
128
|
+
# ACRONYM
|
129
|
+
tag.scan(/acronym(.*?){(.*?)}/).flatten.select{ |x| !x.nil?; add_style("acronym", x) }
|
129
130
|
|
130
|
-
|
131
|
-
|
131
|
+
# ADDRESS
|
132
|
+
tag.scan(/address(.*?){(.*?)}/).flatten.select{ |x| !x.nil?; add_style("address", x) }
|
132
133
|
|
133
|
-
|
134
|
-
|
134
|
+
# APPLET
|
135
|
+
tag.scan(/applet(.*?){(.*?)}/).flatten.select{ |x| !x.nil?; add_style("applet", x) }
|
135
136
|
|
136
|
-
|
137
|
-
|
137
|
+
# AREA
|
138
|
+
tag.scan(/area(.*?){(.*?)}/).flatten.select{ |x| !x.nil?; add_style("area", x) }
|
138
139
|
|
139
|
-
|
140
|
-
|
140
|
+
# ARTICLE
|
141
|
+
tag.scan(/article(.*?){(.*?)}/).flatten.select{ |x| !x.nil?; add_style("article", x) }
|
141
142
|
|
142
|
-
|
143
|
-
|
143
|
+
# ASIDE
|
144
|
+
tag.scan(/aside(.*?){(.*?)}/).flatten.select{ |x| !x.nil?; add_style("aside", x) }
|
144
145
|
|
145
|
-
|
146
|
-
|
146
|
+
# BDI
|
147
|
+
tag.scan(/bdi(.*?){(.*?)}/).flatten.select{ |x| !x.nil?; add_style("bdi", x) }
|
147
148
|
|
148
|
-
|
149
|
-
|
149
|
+
# BIG
|
150
|
+
tag.scan(/big(.*?){(.*?)}/).flatten.select{ |x| !x.nil?; add_style("big", x) }
|
150
151
|
|
151
|
-
|
152
|
-
|
152
|
+
# BLOCKQUOTE
|
153
|
+
tag.scan(/blockquote(.*?){(.*?)}/).flatten.select{ |x| !x.nil?; add_style("blockquote", x) }
|
153
154
|
|
154
|
-
|
155
|
-
|
155
|
+
# CAPTION
|
156
|
+
tag.scan(/caption(.*?){(.*?)}/).flatten.select{ |x| !x.nil?; add_style("caption", x) }
|
156
157
|
|
157
|
-
|
158
|
-
|
158
|
+
# CENTER
|
159
|
+
tag.scan(/center(.*?){(.*?)}/).flatten.select{ |x| !x.nil?; add_style("center", x) }
|
159
160
|
|
160
|
-
|
161
|
-
|
161
|
+
# CITE
|
162
|
+
tag.scan(/cite(.*?){(.*?)}/).flatten.select{ |x| !x.nil?; add_style("cite", x) }
|
162
163
|
|
163
|
-
|
164
|
-
|
164
|
+
# CODE
|
165
|
+
tag.scan(/code(.*?){(.*?)}/).flatten.select{ |x| !x.nil?; add_style("code", x) }
|
165
166
|
|
166
|
-
|
167
|
-
|
167
|
+
# COL
|
168
|
+
tag.scan(/col(.*?){(.*?)}/).flatten.select{ |x| !x.nil?; add_style("col", x) }
|
168
169
|
|
169
|
-
|
170
|
-
|
170
|
+
# COLGROUP
|
171
|
+
tag.scan(/colgroup(.*?){(.*?)}/).flatten.select{ |x| !x.nil?; add_style("colgroup", x) }
|
171
172
|
|
172
|
-
|
173
|
-
|
173
|
+
# DATALIST
|
174
|
+
tag.scan(/datalist(.*?){(.*?)}/).flatten.select{ |x| !x.nil?; add_style("datalist", x) }
|
174
175
|
|
175
|
-
|
176
|
-
|
176
|
+
# DD
|
177
|
+
tag.scan(/dd(.*?){(.*?)}/).flatten.select{ |x| !x.nil?; add_style("dd", x) }
|
177
178
|
|
178
|
-
|
179
|
-
|
179
|
+
# DEL
|
180
|
+
tag.scan(/del(.*?){(.*?)}/).flatten.select{ |x| !x.nil?; add_style("del", x) }
|
180
181
|
|
181
|
-
|
182
|
-
|
182
|
+
# details
|
183
|
+
tag.scan(/details(.*?){(.*?)}/).flatten.select{ |x| !x.nil?; add_style("details", x) }
|
183
184
|
|
184
|
-
|
185
|
-
|
185
|
+
# DFN
|
186
|
+
tag.scan(/dfn(.*?){(.*?)}/).flatten.select{ |x| !x.nil?; add_style("dfn", x) }
|
186
187
|
|
187
|
-
|
188
|
-
|
188
|
+
# DIALOG
|
189
|
+
tag.scan(/dialog(.*?){(.*?)}/).flatten.select{ |x| !x.nil?; add_style("dialog", x) }
|
189
190
|
|
190
|
-
|
191
|
-
|
191
|
+
# DIR
|
192
|
+
tag.scan(/dir(.*?){(.*?)}/).flatten.select{ |x| !x.nil?; add_style("dir", x) }
|
192
193
|
|
193
|
-
|
194
|
-
|
194
|
+
# DL
|
195
|
+
tag.scan(/dl(.*?){(.*?)}/).flatten.select{ |x| !x.nil?; add_style("dl", x) }
|
195
196
|
|
196
|
-
|
197
|
-
|
197
|
+
# DT
|
198
|
+
tag.scan(/dt(.*?){(.*?)}/).flatten.select{ |x| !x.nil?; add_style("dt", x) }
|
198
199
|
|
199
|
-
|
200
|
-
|
200
|
+
# EM
|
201
|
+
tag.scan(/em(.*?){(.*?)}/).flatten.select{ |x| !x.nil?; add_style("em", x) }
|
201
202
|
|
202
|
-
|
203
|
-
|
203
|
+
# FOOTER
|
204
|
+
tag.scan(/footer(.*?){(.*?)}/).flatten.select{ |x| !x.nil?; add_style("footer", x) }
|
204
205
|
|
205
|
-
|
206
|
-
|
206
|
+
# FORM
|
207
|
+
tag.scan(/form(.*?){(.*?)}/).flatten.select{ |x| !x.nil?; add_style("form", x) }
|
207
208
|
|
208
|
-
|
209
|
-
|
209
|
+
# FRAME
|
210
|
+
tag.scan(/frame(.*?){(.*?)}/).flatten.select{ |x| !x.nil?; add_style("frame", x) }
|
210
211
|
|
211
|
-
|
212
|
-
|
212
|
+
# FRAMESET
|
213
|
+
tag.scan(/frameset(.*?){(.*?)}/).flatten.select{ |x| !x.nil?; add_style("frameset", x) }
|
213
214
|
|
214
|
-
|
215
|
-
|
215
|
+
# HR
|
216
|
+
tag.scan(/hr(.*?){(.*?)}/).flatten.select{ |x| !x.nil?; add_style("hr", x) }
|
216
217
|
|
217
|
-
|
218
|
-
|
218
|
+
# IFRAME
|
219
|
+
tag.scan(/iframe(.*?){(.*?)}/).flatten.select{ |x| !x.nil?; add_style("iframe", x) }
|
219
220
|
|
220
|
-
|
221
|
-
|
221
|
+
# IMG
|
222
|
+
tag.scan(/img(.*?){(.*?)}/).flatten.select{ |x| !x.nil?; add_style("img", x) }
|
222
223
|
|
223
|
-
|
224
|
-
|
224
|
+
# INPUT
|
225
|
+
tag.scan(/input(.*?){(.*?)}/).flatten.select{ |x| !x.nil?; add_style("input", x) }
|
225
226
|
|
226
|
-
|
227
|
-
|
227
|
+
# INS
|
228
|
+
tag.scan(/ins(.*?){(.*?)}/).flatten.select{ |x| !x.nil?; add_style("ins", x) }
|
228
229
|
|
229
|
-
|
230
|
-
|
230
|
+
# KBD
|
231
|
+
tag.scan(/kbd(.*?){(.*?)}/).flatten.select{ |x| !x.nil?; add_style("kbd", x) }
|
231
232
|
|
232
|
-
|
233
|
-
|
233
|
+
# KEYGEN
|
234
|
+
tag.scan(/keygen(.*?){(.*?)}/).flatten.select{ |x| !x.nil?; add_style("keygen", x) }
|
234
235
|
|
235
|
-
|
236
|
-
|
236
|
+
# LABEL
|
237
|
+
tag.scan(/label(.*?){(.*?)}/).flatten.select{ |x| !x.nil?; add_style("label", x) }
|
237
238
|
|
238
|
-
|
239
|
-
|
239
|
+
# LEGEND
|
240
|
+
tag.scan(/legend(.*?){(.*?)}/).flatten.select{ |x| !x.nil?; add_style("legend", x) }
|
240
241
|
|
241
|
-
|
242
|
-
|
242
|
+
# LI
|
243
|
+
tag.scan(/li(.*?){(.*?)}/).flatten.select{ |x| !x.nil?; add_style("li", x) }
|
243
244
|
|
244
|
-
|
245
|
-
|
245
|
+
# LINK
|
246
|
+
tag.scan(/link(.*?){(.*?)}/).flatten.select{ |x| !x.nil?; add_style("link", x) }
|
246
247
|
|
247
|
-
|
248
|
-
|
248
|
+
# MAIN
|
249
|
+
tag.scan(/main(.*?){(.*?)}/).flatten.select{ |x| !x.nil?; add_style("main", x) }
|
249
250
|
|
250
|
-
|
251
|
-
|
251
|
+
# MAP
|
252
|
+
tag.scan(/map(.*?){(.*?)}/).flatten.select{ |x| !x.nil?; add_style("map", x) }
|
252
253
|
|
253
|
-
|
254
|
-
|
254
|
+
# MARK
|
255
|
+
tag.scan(/mark(.*?){(.*?)}/).flatten.select{ |x| !x.nil?; add_style("mark", x) }
|
255
256
|
|
256
|
-
|
257
|
-
|
257
|
+
# MENU
|
258
|
+
tag.scan(/menu(.*?){(.*?)}/).flatten.select{ |x| !x.nil?; add_style("menu", x) }
|
258
259
|
|
259
|
-
|
260
|
-
|
260
|
+
# MENUITEM
|
261
|
+
tag.scan(/menuitem(.*?){(.*?)}/).flatten.select{ |x| !x.nil?; add_style("menuitem", x) }
|
261
262
|
|
262
|
-
|
263
|
-
|
263
|
+
# METER
|
264
|
+
tag.scan(/meter(.*?){(.*?)}/).flatten.select{ |x| !x.nil?; add_style("meter", x) }
|
264
265
|
|
265
|
-
|
266
|
-
|
266
|
+
# NAV
|
267
|
+
tag.scan(/nav(.*?){(.*?)}/).flatten.select{ |x| !x.nil?; add_style("nav", x) }
|
267
268
|
|
268
|
-
|
269
|
-
|
269
|
+
# OBJECT
|
270
|
+
tag.scan(/object(.*?){(.*?)}/).flatten.select{ |x| !x.nil?; add_style("object", x) }
|
270
271
|
|
271
|
-
|
272
|
-
|
272
|
+
# OL
|
273
|
+
tag.scan(/ol(.*?){(.*?)}/).flatten.select{ |x| !x.nil?; add_style("ol", x) }
|
273
274
|
|
274
|
-
|
275
|
-
|
275
|
+
# OPTGROUP
|
276
|
+
tag.scan(/optgroup(.*?){(.*?)}/).flatten.select{ |x| !x.nil?; add_style("optgroup", x) }
|
276
277
|
|
277
|
-
|
278
|
-
|
278
|
+
# OPTION
|
279
|
+
tag.scan(/option(.*?){(.*?)}/).flatten.select{ |x| !x.nil?; add_style("option", x) }
|
279
280
|
|
280
|
-
|
281
|
-
|
281
|
+
# OUTPUT
|
282
|
+
tag.scan(/output(.*?){(.*?)}/).flatten.select{ |x| !x.nil?; add_style("output", x) }
|
282
283
|
|
283
|
-
|
284
|
-
|
284
|
+
# PARAM
|
285
|
+
tag.scan(/param(.*?){(.*?)}/).flatten.select{ |x| !x.nil?; add_style("param", x) }
|
285
286
|
|
286
|
-
|
287
|
-
|
287
|
+
# PRE
|
288
|
+
tag.scan(/pre(.*?){(.*?)}/).flatten.select{ |x| !x.nil?; add_style("pre", x) }
|
288
289
|
|
289
|
-
|
290
|
-
|
290
|
+
# PROGRESS
|
291
|
+
tag.scan(/progress(.*?){(.*?)}/).flatten.select{ |x| !x.nil?; add_style("progress", x) }
|
291
292
|
|
292
|
-
|
293
|
-
|
293
|
+
# Q
|
294
|
+
tag.scan(/q{(.*?)}|q\s{(.*?)}/).flatten.select{ |x| !x.nil?; add_style("q", x) }
|
294
295
|
|
295
|
-
|
296
|
-
|
296
|
+
# RP
|
297
|
+
tag.scan(/rp(.*?){(.*?)}/).flatten.select{ |x| !x.nil?; add_style("rp", x) }
|
297
298
|
|
298
|
-
|
299
|
-
|
299
|
+
# RT
|
300
|
+
tag.scan(/rt(.*?){(.*?)}/).flatten.select{ |x| !x.nil?; add_style("rt", x) }
|
300
301
|
|
301
|
-
|
302
|
-
|
302
|
+
# RUBY
|
303
|
+
tag.scan(/ruby(.*?){(.*?)}/).flatten.select{ |x| !x.nil?; add_style("ruby", x) }
|
303
304
|
|
304
|
-
|
305
|
-
|
305
|
+
# S
|
306
|
+
tag.scan(/s{(.*?)}|s\s{(.*?)}/).flatten.select{ |x| !x.nil?; add_style("ruby", x) }
|
306
307
|
|
307
|
-
|
308
|
-
|
308
|
+
# SAMP
|
309
|
+
tag.scan(/samp(.*?){(.*?)}/).flatten.select{ |x| !x.nil?; add_style("samp", x) }
|
309
310
|
|
310
|
-
|
311
|
-
|
311
|
+
# SECTION
|
312
|
+
tag.scan(/section(.*?){(.*?)}/).flatten.select{ |x| !x.nil?; add_style("section", x) }
|
312
313
|
|
313
|
-
|
314
|
-
|
314
|
+
# SELECT
|
315
|
+
tag.scan(/select(.*?){(.*?)}/).flatten.select{ |x| !x.nil?; add_style("select", x) }
|
315
316
|
|
316
|
-
|
317
|
-
|
317
|
+
# SMALL
|
318
|
+
tag.scan(/small(.*?){(.*?)}/).flatten.select{ |x| !x.nil?; add_style("small", x) }
|
318
319
|
|
319
|
-
|
320
|
-
|
320
|
+
# SOURCE
|
321
|
+
tag.scan(/source(.*?){(.*?)}/).flatten.select{ |x| !x.nil?; add_style("source", x) }
|
321
322
|
|
322
|
-
|
323
|
-
|
323
|
+
# STRIKE
|
324
|
+
tag.scan(/strike(.*?){(.*?)}/).flatten.select{ |x| !x.nil?; add_style("strike", x) }
|
324
325
|
|
325
|
-
|
326
|
-
|
326
|
+
# STRONG
|
327
|
+
tag.scan(/strong(.*?){(.*?)}/).flatten.select{ |x| !x.nil?; add_style("strong", x) }
|
327
328
|
|
328
|
-
|
329
|
-
|
329
|
+
# SUB
|
330
|
+
tag.scan(/sub(.*?){(.*?)}/).flatten.select{ |x| !x.nil?; add_style("sub", x) }
|
330
331
|
|
331
|
-
|
332
|
-
|
332
|
+
# SUMMARY
|
333
|
+
tag.scan(/summary(.*?){(.*?)}/).flatten.select{ |x| !x.nil?; add_style("summary", x) }
|
333
334
|
|
334
|
-
|
335
|
-
|
335
|
+
# SUP
|
336
|
+
tag.scan(/sup(.*?){(.*?)}/).flatten.select{ |x| !x.nil?; add_style("sup", x) }
|
336
337
|
|
337
|
-
|
338
|
-
|
338
|
+
# TABLE
|
339
|
+
tag.scan(/table(.*?){(.*?)}/).flatten.select{ |x| !x.nil?; add_style("table", x) }
|
339
340
|
|
340
|
-
|
341
|
-
|
341
|
+
# TBODY
|
342
|
+
tag.scan(/tbody(.*?){(.*?)}/).flatten.select{ |x| !x.nil?; add_style("tbody", x) }
|
342
343
|
|
343
|
-
|
344
|
-
|
344
|
+
# TD
|
345
|
+
tag.scan(/td(.*?){(.*?)}/).flatten.select{ |x| !x.nil?; add_style("td", x) }
|
345
346
|
|
346
|
-
|
347
|
-
|
347
|
+
# TEXTAREA
|
348
|
+
tag.scan(/textarea(.*?){(.*?)}/).flatten.select{ |x| !x.nil?; add_style("textarea", x) }
|
348
349
|
|
349
|
-
|
350
|
-
|
350
|
+
# TFOOT
|
351
|
+
tag.scan(/tfoot(.*?){(.*?)}/).flatten.select{ |x| !x.nil?; add_style("tfoot", x) }
|
351
352
|
|
352
|
-
|
353
|
-
|
353
|
+
# TH
|
354
|
+
tag.scan(/th(.*?){(.*?)}/).flatten.select{ |x| !x.nil?; add_style("th", x) }
|
354
355
|
|
355
|
-
|
356
|
-
|
356
|
+
# THEAD
|
357
|
+
tag.scan(/thead(.*?){(.*?)}/).flatten.select{ |x| !x.nil?; add_style("thead", x) }
|
357
358
|
|
358
|
-
|
359
|
-
|
359
|
+
# TIME
|
360
|
+
tag.scan(/time(.*?){(.*?)}/).flatten.select{ |x| !x.nil?; add_style("time", x) }
|
360
361
|
|
361
|
-
|
362
|
-
|
362
|
+
# TR
|
363
|
+
tag.scan(/tr(.*?){(.*?)}/).flatten.select{ |x| !x.nil?; add_style("tr", x) }
|
363
364
|
|
364
|
-
|
365
|
-
|
365
|
+
# TRACK
|
366
|
+
tag.scan(/track(.*?){(.*?)}/).flatten.select{ |x| !x.nil?; add_style("track", x) }
|
366
367
|
|
367
|
-
|
368
|
-
|
368
|
+
# TT
|
369
|
+
tag.scan(/tt(.*?){(.*?)}/).flatten.select{ |x| !x.nil?; add_style("tt", x) }
|
369
370
|
|
370
|
-
|
371
|
-
|
371
|
+
# U
|
372
|
+
tag.scan(/u{(.*?)}|u\s{(.*?)}/).flatten.select{ |x| !x.nil?; add_style("u", x) }
|
372
373
|
|
373
|
-
|
374
|
-
|
374
|
+
# UL
|
375
|
+
tag.scan(/ul(.*?){(.*?)}/).flatten.select{ |x| !x.nil?; add_style("ul", x) }
|
375
376
|
|
376
|
-
|
377
|
-
|
377
|
+
# VAR
|
378
|
+
tag.scan(/var(.*?){(.*?)}/).flatten.select{ |x| !x.nil?; add_style("var", x) }
|
378
379
|
|
379
|
-
|
380
|
-
|
380
|
+
# WBR
|
381
|
+
tag.scan(/wbr(.*?){(.*?)}/).flatten.select{ |x| !x.nil?; add_style("wbr", x) }
|
381
382
|
|
382
|
-
|
383
|
-
|
384
|
-
|
385
|
-
|
386
|
-
|
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
|
-
|
389
|
-
|
390
|
-
|
391
|
-
|
392
|
-
|
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
|