htmlmin 0.0.6 → 0.0.7
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.
- data/README.md +10 -4
- data/lib/htmlmin.rb +8 -0
- data/lib/htmlmin/attr_buffer.rb +77 -0
- data/lib/htmlmin/buffer.rb +1 -1
- data/lib/htmlmin/slot_machines.rb +1 -0
- data/lib/htmlmin/slot_machines/attr.rb +72 -0
- data/lib/htmlmin/slot_machines/comment.rb +2 -0
- data/lib/htmlmin/slot_machines/common.rb +27 -3
- data/lib/htmlmin/slot_machines/doctype.rb +40 -2
- data/lib/htmlmin/slot_machines/tag.rb +35 -0
- data/lib/htmlmin/version.rb +1 -1
- data/test/input/doctype_4.txt +6 -0
- data/test/input/doctype_5.txt +2 -0
- data/test/input/doctype_6.txt +2 -0
- data/test/input/shorttag_1.txt +6 -0
- data/test/input/shorttag_2.txt +6 -0
- data/test/options/doctype_4.rb +9 -0
- data/test/options/doctype_5.rb +9 -0
- data/test/options/doctype_6.rb +9 -0
- data/test/options/shorttag_1.rb +12 -0
- data/test/options/shorttag_2.rb +12 -0
- data/test/output/doctype_4.txt +2 -0
- data/test/output/doctype_5.txt +1 -0
- data/test/output/doctype_6.txt +1 -0
- data/test/output/shorttag_1.txt +1 -0
- data/test/output/shorttag_2.txt +1 -0
- metadata +34 -2
data/README.md
CHANGED
@@ -8,7 +8,7 @@ Please report issues on [Github] (https://github.com/aishek/htmlmin/issues).
|
|
8
8
|
|
9
9
|
For feedback, suggestions, etc. write to <aishek@gmail.com>.
|
10
10
|
|
11
|
-
**Important**: this project is in beta and may contain bugs. Current version: 0.0.
|
11
|
+
**Important**: this project is in beta and may contain bugs. Current version: 0.0.7
|
12
12
|
|
13
13
|
# Installation
|
14
14
|
|
@@ -22,6 +22,10 @@ Usage:
|
|
22
22
|
|
23
23
|
require 'htmlmin'
|
24
24
|
options = {
|
25
|
+
:indent_doctype => true, # inserts "\n" after first doctype declaration
|
26
|
+
|
27
|
+
:minify_shorttag_closer => false, # e.g. <br/> => <br>
|
28
|
+
|
25
29
|
:remove_comments => true,
|
26
30
|
:remove_conditional_comments => true, # only downlevel-hidden conditional comments e.g. <!--[if expression]> HTML <![endif]-->
|
27
31
|
|
@@ -36,11 +40,13 @@ Usage:
|
|
36
40
|
|
37
41
|
# Minification
|
38
42
|
|
39
|
-
* Insert newline after DOCTYPE declaration
|
40
43
|
* Removal of whitespace
|
41
44
|
* Removal of comments
|
42
45
|
* Minification of HTML entities
|
43
46
|
* Replace HTML entities by equal chars
|
47
|
+
* Minify shorttag close symbol
|
48
|
+
* Minify shorttag close whitespace
|
49
|
+
* Insert newline after DOCTYPE declaration
|
44
50
|
|
45
51
|
# Development roadmap
|
46
52
|
|
@@ -55,8 +61,8 @@ Usage:
|
|
55
61
|
* Do not perform minify in code, samp, pre tags's content
|
56
62
|
* ~~Replace entities with numeric entities for shorter strings~~
|
57
63
|
* ~~Replace entities with characters for shorter strings~~
|
58
|
-
* Minify shorttag close symbol
|
59
|
-
* Minify shorttag close whitespace
|
64
|
+
* ~~Minify shorttag close symbol~~
|
65
|
+
* ~~Minify shorttag close whitespace~~
|
60
66
|
* Replace http:// with // in href and src attributes
|
61
67
|
* Minify whitespaces between tag attributes
|
62
68
|
* Minify quotes in one-word attributes
|
data/lib/htmlmin.rb
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
require "htmlmin/version"
|
2
2
|
require "htmlmin/buffer"
|
3
|
+
require "htmlmin/attr_buffer"
|
3
4
|
require "htmlmin/state"
|
4
5
|
require "htmlmin/max_line_len"
|
5
6
|
require "htmlmin/slot_machines"
|
@@ -21,10 +22,16 @@ module HTMLMin
|
|
21
22
|
extend HTMLMin::SlotMachines::Doctype
|
22
23
|
extend HTMLMin::SlotMachines::Entity
|
23
24
|
extend HTMLMin::SlotMachines::Tag
|
25
|
+
extend HTMLMin::AttrBuffer
|
26
|
+
extend HTMLMin::SlotMachines::Attr
|
24
27
|
|
25
28
|
class << self
|
26
29
|
|
27
30
|
DEFAULT_OPTIONS = {
|
31
|
+
:indent_doctype => true,
|
32
|
+
|
33
|
+
:minify_shorttag_closer => true,
|
34
|
+
|
28
35
|
:remove_comments => true,
|
29
36
|
:remove_conditional_comments => true,
|
30
37
|
|
@@ -57,6 +64,7 @@ module HTMLMin
|
|
57
64
|
|
58
65
|
def init_slot_machine
|
59
66
|
init_max_line_len
|
67
|
+
expect_doctype
|
60
68
|
clear_buffer
|
61
69
|
|
62
70
|
reset_saved_state
|
@@ -0,0 +1,77 @@
|
|
1
|
+
module HTMLMin
|
2
|
+
|
3
|
+
module AttrBuffer
|
4
|
+
|
5
|
+
private
|
6
|
+
|
7
|
+
SPACES = ["\s", "\n", "\r", "\t", " "]
|
8
|
+
|
9
|
+
def clear_attr_buffer
|
10
|
+
@attr_buffer = []
|
11
|
+
end
|
12
|
+
|
13
|
+
def start_attr_buffer
|
14
|
+
@attr_buffer << ""
|
15
|
+
end
|
16
|
+
|
17
|
+
def start_attr_buffer_spaces
|
18
|
+
start_attr_buffer if @attr_buffer.empty? || !(@attr_buffer.last.is_a? String)
|
19
|
+
end
|
20
|
+
|
21
|
+
def last_attr_buffer_item
|
22
|
+
@attr_buffer.last.is_a?(Array) ? @attr_buffer.last.last : @attr_buffer.last
|
23
|
+
end
|
24
|
+
|
25
|
+
def add_to_attr_buffer(char)
|
26
|
+
last_attr_buffer_item << char
|
27
|
+
end
|
28
|
+
|
29
|
+
def process_attr_buffer
|
30
|
+
new_attr_buffer = []
|
31
|
+
@attr_buffer.each do |item|
|
32
|
+
new_item = minify_attr_buffer_item_spaces(item)
|
33
|
+
new_attr_buffer << new_item
|
34
|
+
end
|
35
|
+
new_attr_buffer = remove_shorttag_closer(new_attr_buffer) if @settings[:minify_shorttag_closer]
|
36
|
+
new_attr_buffer = remove_end_whitespaces(new_attr_buffer)
|
37
|
+
|
38
|
+
@attr_buffer = new_attr_buffer
|
39
|
+
end
|
40
|
+
|
41
|
+
def remove_end_whitespaces(buffer)
|
42
|
+
reversed = buffer.reverse
|
43
|
+
shorttag = reversed.first == '/'
|
44
|
+
reversed.shift if shorttag
|
45
|
+
|
46
|
+
result = reversed.drop_while {|item| item == ' ' }
|
47
|
+
result = result.reverse
|
48
|
+
result << '/' if shorttag
|
49
|
+
|
50
|
+
result
|
51
|
+
end
|
52
|
+
|
53
|
+
def remove_shorttag_closer(buffer)
|
54
|
+
buffer.pop
|
55
|
+
buffer
|
56
|
+
end
|
57
|
+
|
58
|
+
def minify_attr_buffer_item_spaces(item)
|
59
|
+
new_item = item
|
60
|
+
unless item.is_a? Array
|
61
|
+
new_item = new_item.chars.drop_while {|char| SPACES.include? char }
|
62
|
+
new_item = new_item.join
|
63
|
+
new_item = ' ' if new_item.empty?
|
64
|
+
end
|
65
|
+
new_item
|
66
|
+
end
|
67
|
+
|
68
|
+
def flush_attr_buffer
|
69
|
+
attr_buffer_chars = @attr_buffer.flatten.join.chars
|
70
|
+
attr_buffer_chars.each do |char|
|
71
|
+
add_to_buffer char
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
end
|
76
|
+
|
77
|
+
end
|
data/lib/htmlmin/buffer.rb
CHANGED
@@ -0,0 +1,72 @@
|
|
1
|
+
module HTMLMin
|
2
|
+
|
3
|
+
module SlotMachines
|
4
|
+
|
5
|
+
module Attr
|
6
|
+
|
7
|
+
private
|
8
|
+
|
9
|
+
def tag_attr_spaces(char)
|
10
|
+
case char
|
11
|
+
# when 'a'..'z', 'A'..'Z'
|
12
|
+
# add_to_buffer char
|
13
|
+
when "\s", "\n", "\r", "\t", " "
|
14
|
+
start_attr_buffer_spaces
|
15
|
+
add_to_attr_buffer char
|
16
|
+
|
17
|
+
change_state_to :tag_attr_spaces
|
18
|
+
when '/'
|
19
|
+
start_attr_buffer
|
20
|
+
add_to_attr_buffer char
|
21
|
+
|
22
|
+
change_state_to :tag_attr_spaces_tag_end_char_expected
|
23
|
+
when '>'
|
24
|
+
unshift_spaces_from_buffer if saved_state_unshiftable?
|
25
|
+
|
26
|
+
flush_attr_buffer
|
27
|
+
add_to_buffer char
|
28
|
+
flush_buffer
|
29
|
+
|
30
|
+
change_state_to :entity_ended
|
31
|
+
when HTMLMin::Minifier::END_OF_FILE
|
32
|
+
flush_buffer
|
33
|
+
else
|
34
|
+
reset_saved_state
|
35
|
+
|
36
|
+
flush_attr_buffer
|
37
|
+
flush_buffer
|
38
|
+
|
39
|
+
add_to_result char
|
40
|
+
change_state_to :start
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
def tag_attr_spaces_tag_end_char_expected(char)
|
45
|
+
case char
|
46
|
+
when '>'
|
47
|
+
unshift_spaces_from_buffer if saved_state_unshiftable?
|
48
|
+
|
49
|
+
process_attr_buffer
|
50
|
+
flush_attr_buffer
|
51
|
+
add_to_buffer char
|
52
|
+
flush_buffer
|
53
|
+
|
54
|
+
change_state_to :entity_ended
|
55
|
+
when HTMLMin::Minifier::END_OF_FILE
|
56
|
+
flush_buffer
|
57
|
+
else
|
58
|
+
reset_saved_state
|
59
|
+
|
60
|
+
flush_attr_buffer
|
61
|
+
flush_buffer
|
62
|
+
|
63
|
+
add_to_result char
|
64
|
+
change_state_to :start
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
end
|
69
|
+
|
70
|
+
end
|
71
|
+
|
72
|
+
end
|
@@ -17,6 +17,7 @@ module HTMLMin
|
|
17
17
|
when HTMLMin::Minifier::END_OF_FILE
|
18
18
|
flush_buffer
|
19
19
|
when '&'
|
20
|
+
expect_no_doctype
|
20
21
|
reset_saved_state
|
21
22
|
|
22
23
|
flush_buffer
|
@@ -24,6 +25,7 @@ module HTMLMin
|
|
24
25
|
add_to_buffer char
|
25
26
|
change_state_to :entity
|
26
27
|
else
|
28
|
+
expect_no_doctype
|
27
29
|
reset_saved_state
|
28
30
|
|
29
31
|
flush_buffer
|
@@ -12,14 +12,19 @@ module HTMLMin
|
|
12
12
|
add_to_buffer char
|
13
13
|
change_state_to :comment_or_doctype_begin
|
14
14
|
when "/"
|
15
|
+
expect_no_doctype
|
16
|
+
|
15
17
|
add_to_buffer char
|
16
18
|
change_state_to :tagend_body_expected
|
17
19
|
when 'a'..'z', 'A'..'Z'
|
20
|
+
expect_no_doctype
|
21
|
+
|
18
22
|
add_to_buffer char
|
19
23
|
change_state_to :tag
|
20
24
|
when HTMLMin::Minifier::END_OF_FILE
|
21
25
|
flush_buffer
|
22
26
|
else
|
27
|
+
expect_no_doctype
|
23
28
|
reset_saved_state
|
24
29
|
|
25
30
|
flush_buffer
|
@@ -35,10 +40,20 @@ module HTMLMin
|
|
35
40
|
add_to_buffer char
|
36
41
|
change_state_to :comment_begin_1
|
37
42
|
when 'D'
|
38
|
-
|
39
|
-
|
43
|
+
if expect_doctype?
|
44
|
+
add_to_buffer char
|
45
|
+
change_state_to :doctype_begin_1
|
46
|
+
else
|
47
|
+
reset_saved_state
|
48
|
+
|
49
|
+
flush_buffer
|
50
|
+
|
51
|
+
add_to_result char
|
52
|
+
change_state_to :start
|
53
|
+
end
|
40
54
|
when '&'
|
41
55
|
reset_saved_state
|
56
|
+
expect_no_doctype
|
42
57
|
|
43
58
|
flush_buffer
|
44
59
|
|
@@ -48,6 +63,7 @@ module HTMLMin
|
|
48
63
|
flush_buffer
|
49
64
|
else
|
50
65
|
reset_saved_state
|
66
|
+
expect_no_doctype
|
51
67
|
|
52
68
|
flush_buffer
|
53
69
|
|
@@ -57,7 +73,7 @@ module HTMLMin
|
|
57
73
|
end
|
58
74
|
|
59
75
|
def add_to_result(char)
|
60
|
-
@result
|
76
|
+
@result << char
|
61
77
|
|
62
78
|
check_max_line_len(char) if @settings[:max_line_len] > 0
|
63
79
|
end
|
@@ -78,6 +94,8 @@ module HTMLMin
|
|
78
94
|
flush_buffer if saved_state_empty?
|
79
95
|
change_state_to_tag_or_tagend_or_comment_or_doctype_begin char
|
80
96
|
when '&'
|
97
|
+
expect_no_doctype
|
98
|
+
|
81
99
|
reset_saved_state
|
82
100
|
flush_buffer
|
83
101
|
|
@@ -86,6 +104,8 @@ module HTMLMin
|
|
86
104
|
when HTMLMin::Minifier::END_OF_FILE
|
87
105
|
flush_buffer
|
88
106
|
else
|
107
|
+
expect_no_doctype
|
108
|
+
|
89
109
|
reset_saved_state
|
90
110
|
flush_buffer
|
91
111
|
|
@@ -101,11 +121,15 @@ module HTMLMin
|
|
101
121
|
when "<"
|
102
122
|
change_state_to_tag_or_tagend_or_comment_or_doctype_begin char
|
103
123
|
when '&'
|
124
|
+
expect_no_doctype
|
125
|
+
|
104
126
|
add_to_buffer char
|
105
127
|
change_state_to :entity
|
106
128
|
when HTMLMin::Minifier::END_OF_FILE
|
107
129
|
flush_buffer
|
108
130
|
else
|
131
|
+
expect_no_doctype
|
132
|
+
|
109
133
|
add_to_result char
|
110
134
|
change_state_to :start
|
111
135
|
end
|
@@ -6,6 +6,22 @@ module HTMLMin
|
|
6
6
|
|
7
7
|
private
|
8
8
|
|
9
|
+
def expect_doctype
|
10
|
+
@expect_doctype = true
|
11
|
+
end
|
12
|
+
|
13
|
+
def expect_doctype?
|
14
|
+
@expect_doctype
|
15
|
+
end
|
16
|
+
|
17
|
+
def expect_no_doctype
|
18
|
+
@expect_doctype = false
|
19
|
+
end
|
20
|
+
|
21
|
+
def indent_doctype?
|
22
|
+
@settings[:indent_doctype]
|
23
|
+
end
|
24
|
+
|
9
25
|
def doctype_begin_1(char)
|
10
26
|
case char
|
11
27
|
when "O"
|
@@ -13,12 +29,14 @@ module HTMLMin
|
|
13
29
|
change_state_to :doctype_begin_2
|
14
30
|
when "\s", "\n", "\r", "\t", " "
|
15
31
|
reset_saved_state
|
32
|
+
expect_no_doctype
|
16
33
|
|
17
34
|
flush_buffer
|
18
35
|
|
19
36
|
change_state_to_spaces char
|
20
37
|
when '&'
|
21
38
|
reset_saved_state
|
39
|
+
expect_no_doctype
|
22
40
|
|
23
41
|
flush_buffer
|
24
42
|
|
@@ -28,6 +46,7 @@ module HTMLMin
|
|
28
46
|
flush_buffer
|
29
47
|
else
|
30
48
|
reset_saved_state
|
49
|
+
expect_no_doctype
|
31
50
|
|
32
51
|
flush_buffer
|
33
52
|
|
@@ -43,6 +62,7 @@ module HTMLMin
|
|
43
62
|
change_state_to :doctype_begin_3
|
44
63
|
when '&'
|
45
64
|
reset_saved_state
|
65
|
+
expect_no_doctype
|
46
66
|
|
47
67
|
flush_buffer
|
48
68
|
|
@@ -50,6 +70,7 @@ module HTMLMin
|
|
50
70
|
change_state_to :entity
|
51
71
|
when "\s", "\n", "\r", "\t", " "
|
52
72
|
reset_saved_state
|
73
|
+
expect_no_doctype
|
53
74
|
|
54
75
|
flush_buffer
|
55
76
|
change_state_to_spaces char
|
@@ -57,6 +78,7 @@ module HTMLMin
|
|
57
78
|
flush_buffer
|
58
79
|
else
|
59
80
|
reset_saved_state
|
81
|
+
expect_no_doctype
|
60
82
|
|
61
83
|
flush_buffer
|
62
84
|
|
@@ -72,6 +94,7 @@ module HTMLMin
|
|
72
94
|
change_state_to :doctype_begin_4
|
73
95
|
when '&'
|
74
96
|
reset_saved_state
|
97
|
+
expect_no_doctype
|
75
98
|
|
76
99
|
flush_buffer
|
77
100
|
|
@@ -79,6 +102,7 @@ module HTMLMin
|
|
79
102
|
change_state_to :entity
|
80
103
|
when "\s", "\n", "\r", "\t", " "
|
81
104
|
reset_saved_state
|
105
|
+
expect_no_doctype
|
82
106
|
|
83
107
|
flush_buffer
|
84
108
|
change_state_to_spaces char
|
@@ -86,6 +110,7 @@ module HTMLMin
|
|
86
110
|
flush_buffer
|
87
111
|
else
|
88
112
|
reset_saved_state
|
113
|
+
expect_no_doctype
|
89
114
|
|
90
115
|
flush_buffer
|
91
116
|
|
@@ -101,6 +126,7 @@ module HTMLMin
|
|
101
126
|
change_state_to :doctype_begin_5
|
102
127
|
when '&'
|
103
128
|
reset_saved_state
|
129
|
+
expect_no_doctype
|
104
130
|
|
105
131
|
flush_buffer
|
106
132
|
|
@@ -108,6 +134,7 @@ module HTMLMin
|
|
108
134
|
change_state_to :entity
|
109
135
|
when "\s", "\n", "\r", "\t", " "
|
110
136
|
reset_saved_state
|
137
|
+
expect_no_doctype
|
111
138
|
|
112
139
|
flush_buffer
|
113
140
|
change_state_to_spaces char
|
@@ -115,6 +142,7 @@ module HTMLMin
|
|
115
142
|
flush_buffer
|
116
143
|
else
|
117
144
|
reset_saved_state
|
145
|
+
expect_no_doctype
|
118
146
|
|
119
147
|
flush_buffer
|
120
148
|
|
@@ -130,6 +158,7 @@ module HTMLMin
|
|
130
158
|
change_state_to :doctype_begin_6
|
131
159
|
when '&'
|
132
160
|
reset_saved_state
|
161
|
+
expect_no_doctype
|
133
162
|
|
134
163
|
flush_buffer
|
135
164
|
|
@@ -137,6 +166,7 @@ module HTMLMin
|
|
137
166
|
change_state_to :entity
|
138
167
|
when "\s", "\n", "\r", "\t", " "
|
139
168
|
reset_saved_state
|
169
|
+
expect_no_doctype
|
140
170
|
|
141
171
|
flush_buffer
|
142
172
|
change_state_to_spaces char
|
@@ -144,6 +174,7 @@ module HTMLMin
|
|
144
174
|
flush_buffer
|
145
175
|
else
|
146
176
|
reset_saved_state
|
177
|
+
expect_no_doctype
|
147
178
|
|
148
179
|
flush_buffer
|
149
180
|
|
@@ -159,6 +190,7 @@ module HTMLMin
|
|
159
190
|
change_state_to :doctype_begin_7
|
160
191
|
when '&'
|
161
192
|
reset_saved_state
|
193
|
+
expect_no_doctype
|
162
194
|
|
163
195
|
flush_buffer
|
164
196
|
|
@@ -166,6 +198,7 @@ module HTMLMin
|
|
166
198
|
change_state_to :entity
|
167
199
|
when "\s", "\n", "\r", "\t", " "
|
168
200
|
reset_saved_state
|
201
|
+
expect_no_doctype
|
169
202
|
|
170
203
|
flush_buffer
|
171
204
|
change_state_to_spaces char
|
@@ -173,6 +206,7 @@ module HTMLMin
|
|
173
206
|
flush_buffer
|
174
207
|
else
|
175
208
|
reset_saved_state
|
209
|
+
expect_no_doctype
|
176
210
|
|
177
211
|
flush_buffer
|
178
212
|
|
@@ -191,6 +225,7 @@ module HTMLMin
|
|
191
225
|
change_state_to :doctype
|
192
226
|
when '&'
|
193
227
|
reset_saved_state
|
228
|
+
expect_no_doctype
|
194
229
|
|
195
230
|
flush_buffer
|
196
231
|
|
@@ -198,6 +233,7 @@ module HTMLMin
|
|
198
233
|
change_state_to :entity
|
199
234
|
when "\s", "\n", "\r", "\t"
|
200
235
|
reset_saved_state
|
236
|
+
expect_no_doctype
|
201
237
|
|
202
238
|
flush_buffer
|
203
239
|
change_state_to_spaces char
|
@@ -205,6 +241,7 @@ module HTMLMin
|
|
205
241
|
flush_buffer
|
206
242
|
else
|
207
243
|
reset_saved_state
|
244
|
+
expect_no_doctype
|
208
245
|
|
209
246
|
flush_buffer
|
210
247
|
|
@@ -220,12 +257,13 @@ module HTMLMin
|
|
220
257
|
|
221
258
|
flush_buffer
|
222
259
|
|
223
|
-
add_to_result "\n"
|
260
|
+
add_to_result "\n" if indent_doctype?
|
261
|
+
|
262
|
+
expect_no_doctype
|
224
263
|
change_state_to :entity_ended
|
225
264
|
when HTMLMin::Minifier::END_OF_FILE
|
226
265
|
flush_buffer
|
227
266
|
else
|
228
|
-
|
229
267
|
add_to_buffer char
|
230
268
|
end
|
231
269
|
end
|
@@ -10,6 +10,41 @@ module HTMLMin
|
|
10
10
|
case char
|
11
11
|
when 'a'..'z', 'A'..'Z'
|
12
12
|
add_to_buffer char
|
13
|
+
when "\s", "\n", "\r", "\t", " "
|
14
|
+
clear_attr_buffer
|
15
|
+
|
16
|
+
start_attr_buffer_spaces
|
17
|
+
add_to_attr_buffer char
|
18
|
+
|
19
|
+
change_state_to :tag_attr_spaces
|
20
|
+
when '/'
|
21
|
+
clear_attr_buffer
|
22
|
+
|
23
|
+
start_attr_buffer
|
24
|
+
add_to_attr_buffer char
|
25
|
+
|
26
|
+
change_state_to :tag_attr_spaces_tag_end_char_expected
|
27
|
+
when '>'
|
28
|
+
unshift_spaces_from_buffer if saved_state_unshiftable?
|
29
|
+
|
30
|
+
add_to_buffer char
|
31
|
+
flush_buffer
|
32
|
+
|
33
|
+
change_state_to :entity_ended
|
34
|
+
when HTMLMin::Minifier::END_OF_FILE
|
35
|
+
flush_buffer
|
36
|
+
else
|
37
|
+
reset_saved_state
|
38
|
+
|
39
|
+
flush_buffer
|
40
|
+
|
41
|
+
add_to_result char
|
42
|
+
change_state_to :start
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
def tag_end_char_expected(char)
|
47
|
+
case char
|
13
48
|
when '>'
|
14
49
|
unshift_spaces_from_buffer if saved_state_unshiftable?
|
15
50
|
|
data/lib/htmlmin/version.rb
CHANGED
@@ -0,0 +1,6 @@
|
|
1
|
+
<!-- -->
|
2
|
+
<!-- -->
|
3
|
+
|
4
|
+
|
5
|
+
|
6
|
+
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
@@ -0,0 +1 @@
|
|
1
|
+
x <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><head>
|
@@ -0,0 +1 @@
|
|
1
|
+
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><head>
|
@@ -0,0 +1 @@
|
|
1
|
+
<br/><br/><div/>
|
@@ -0,0 +1 @@
|
|
1
|
+
<br><br><div>
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: htmlmin
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.7
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2011-
|
12
|
+
date: 2011-09-05 00:00:00.000000000Z
|
13
13
|
dependencies: []
|
14
14
|
description: HTMLMin is a HTML-code minification tool implemented in Ruby. It works
|
15
15
|
like a slot machine.
|
@@ -25,9 +25,11 @@ files:
|
|
25
25
|
- Rakefile
|
26
26
|
- htmlmin.gemspec
|
27
27
|
- lib/htmlmin.rb
|
28
|
+
- lib/htmlmin/attr_buffer.rb
|
28
29
|
- lib/htmlmin/buffer.rb
|
29
30
|
- lib/htmlmin/max_line_len.rb
|
30
31
|
- lib/htmlmin/slot_machines.rb
|
32
|
+
- lib/htmlmin/slot_machines/attr.rb
|
31
33
|
- lib/htmlmin/slot_machines/comment.rb
|
32
34
|
- lib/htmlmin/slot_machines/common.rb
|
33
35
|
- lib/htmlmin/slot_machines/doctype.rb
|
@@ -48,12 +50,17 @@ files:
|
|
48
50
|
- test/input/doctype_1.txt
|
49
51
|
- test/input/doctype_2.txt
|
50
52
|
- test/input/doctype_3.txt
|
53
|
+
- test/input/doctype_4.txt
|
54
|
+
- test/input/doctype_5.txt
|
55
|
+
- test/input/doctype_6.txt
|
51
56
|
- test/input/entity_1.txt
|
52
57
|
- test/input/entity_2.txt
|
53
58
|
- test/input/line_length_1.txt
|
54
59
|
- test/input/line_length_2.txt
|
55
60
|
- test/input/line_length_3.txt
|
56
61
|
- test/input/line_length_4.txt
|
62
|
+
- test/input/shorttag_1.txt
|
63
|
+
- test/input/shorttag_2.txt
|
57
64
|
- test/input/tag_1.txt
|
58
65
|
- test/input/tag_2.txt
|
59
66
|
- test/input/tag_3.txt
|
@@ -67,12 +74,17 @@ files:
|
|
67
74
|
- test/options/comment_7.rb
|
68
75
|
- test/options/comment_8.rb
|
69
76
|
- test/options/doctype_3.rb
|
77
|
+
- test/options/doctype_4.rb
|
78
|
+
- test/options/doctype_5.rb
|
79
|
+
- test/options/doctype_6.rb
|
70
80
|
- test/options/entity_1.rb
|
71
81
|
- test/options/entity_2.rb
|
72
82
|
- test/options/line_length_1.rb
|
73
83
|
- test/options/line_length_2.rb
|
74
84
|
- test/options/line_length_3.rb
|
75
85
|
- test/options/line_length_4.rb
|
86
|
+
- test/options/shorttag_1.rb
|
87
|
+
- test/options/shorttag_2.rb
|
76
88
|
- test/options/tag_2.rb
|
77
89
|
- test/options/tag_3.rb
|
78
90
|
- test/output/cc_1.txt
|
@@ -88,12 +100,17 @@ files:
|
|
88
100
|
- test/output/doctype_1.txt
|
89
101
|
- test/output/doctype_2.txt
|
90
102
|
- test/output/doctype_3.txt
|
103
|
+
- test/output/doctype_4.txt
|
104
|
+
- test/output/doctype_5.txt
|
105
|
+
- test/output/doctype_6.txt
|
91
106
|
- test/output/entity_1.txt
|
92
107
|
- test/output/entity_2.txt
|
93
108
|
- test/output/line_length_1.txt
|
94
109
|
- test/output/line_length_2.txt
|
95
110
|
- test/output/line_length_3.txt
|
96
111
|
- test/output/line_length_4.txt
|
112
|
+
- test/output/shorttag_1.txt
|
113
|
+
- test/output/shorttag_2.txt
|
97
114
|
- test/output/tag_1.txt
|
98
115
|
- test/output/tag_2.txt
|
99
116
|
- test/output/tag_3.txt
|
@@ -140,12 +157,17 @@ test_files:
|
|
140
157
|
- test/input/doctype_1.txt
|
141
158
|
- test/input/doctype_2.txt
|
142
159
|
- test/input/doctype_3.txt
|
160
|
+
- test/input/doctype_4.txt
|
161
|
+
- test/input/doctype_5.txt
|
162
|
+
- test/input/doctype_6.txt
|
143
163
|
- test/input/entity_1.txt
|
144
164
|
- test/input/entity_2.txt
|
145
165
|
- test/input/line_length_1.txt
|
146
166
|
- test/input/line_length_2.txt
|
147
167
|
- test/input/line_length_3.txt
|
148
168
|
- test/input/line_length_4.txt
|
169
|
+
- test/input/shorttag_1.txt
|
170
|
+
- test/input/shorttag_2.txt
|
149
171
|
- test/input/tag_1.txt
|
150
172
|
- test/input/tag_2.txt
|
151
173
|
- test/input/tag_3.txt
|
@@ -159,12 +181,17 @@ test_files:
|
|
159
181
|
- test/options/comment_7.rb
|
160
182
|
- test/options/comment_8.rb
|
161
183
|
- test/options/doctype_3.rb
|
184
|
+
- test/options/doctype_4.rb
|
185
|
+
- test/options/doctype_5.rb
|
186
|
+
- test/options/doctype_6.rb
|
162
187
|
- test/options/entity_1.rb
|
163
188
|
- test/options/entity_2.rb
|
164
189
|
- test/options/line_length_1.rb
|
165
190
|
- test/options/line_length_2.rb
|
166
191
|
- test/options/line_length_3.rb
|
167
192
|
- test/options/line_length_4.rb
|
193
|
+
- test/options/shorttag_1.rb
|
194
|
+
- test/options/shorttag_2.rb
|
168
195
|
- test/options/tag_2.rb
|
169
196
|
- test/options/tag_3.rb
|
170
197
|
- test/output/cc_1.txt
|
@@ -180,12 +207,17 @@ test_files:
|
|
180
207
|
- test/output/doctype_1.txt
|
181
208
|
- test/output/doctype_2.txt
|
182
209
|
- test/output/doctype_3.txt
|
210
|
+
- test/output/doctype_4.txt
|
211
|
+
- test/output/doctype_5.txt
|
212
|
+
- test/output/doctype_6.txt
|
183
213
|
- test/output/entity_1.txt
|
184
214
|
- test/output/entity_2.txt
|
185
215
|
- test/output/line_length_1.txt
|
186
216
|
- test/output/line_length_2.txt
|
187
217
|
- test/output/line_length_3.txt
|
188
218
|
- test/output/line_length_4.txt
|
219
|
+
- test/output/shorttag_1.txt
|
220
|
+
- test/output/shorttag_2.txt
|
189
221
|
- test/output/tag_1.txt
|
190
222
|
- test/output/tag_2.txt
|
191
223
|
- test/output/tag_3.txt
|