h5-min 0.0.1 → 0.1.0
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/Rakefile +1 -0
- data/VERSION +1 -1
- data/bin/h5-min +1 -1
- data/fixtures/attribute-value-ampersand.html +4 -0
- data/fixtures/attribute-value-ampersand.html.min +1 -0
- data/fixtures/attribute-value-quot.html +4 -0
- data/fixtures/attribute-value-quot.html.min +1 -0
- data/fixtures/dl.html +10 -0
- data/fixtures/dl.html.min +1 -0
- data/fixtures/entities-expand.html +4 -0
- data/fixtures/entities-expand.html.min +1 -0
- data/fixtures/entities-no-expand.html +3 -0
- data/fixtures/entities-no-expand.html.min +1 -0
- data/fixtures/ie.html.min +1 -1
- data/fixtures/lists.html +8 -0
- data/fixtures/lists.html.min +1 -0
- data/fixtures/normalise-attribute-name.html +4 -0
- data/fixtures/normalise-attribute-name.html.min +1 -0
- data/fixtures/normalise-tag-name.html +5 -0
- data/fixtures/normalise-tag-name.html.min +1 -0
- data/fixtures/pre-entities.html +7 -0
- data/fixtures/pre-entities.html.min +4 -0
- data/fixtures/pre.html.min +1 -1
- data/fixtures/skeleton.html.min +1 -1
- data/fixtures/sort-attributes.html +4 -0
- data/fixtures/sort-attributes.html.min +1 -0
- data/fixtures/table.html +21 -0
- data/fixtures/table.html.min +1 -0
- data/fixtures/whitespace-complex.html +9 -0
- data/fixtures/whitespace-complex.html.min +1 -0
- data/fixtures/whitespace-p.html +4 -0
- data/fixtures/whitespace-p.html.min +1 -0
- data/lib/h5-min/optional.rb +134 -0
- data/lib/h5-min.rb +87 -49
- data/spec/h5-min_spec.rb +25 -14
- metadata +49 -7
data/Rakefile
CHANGED
|
@@ -10,6 +10,7 @@ begin
|
|
|
10
10
|
gem.email = "runrun@runpaint.org"
|
|
11
11
|
gem.homepage = "http://github.com/runpaint/h5-min"
|
|
12
12
|
gem.authors = ["Run Paint Run Run"]
|
|
13
|
+
gem.add_dependency "htmlentities", ">= 4.1.0"
|
|
13
14
|
gem.add_development_dependency "rspec", ">= 1.2.9"
|
|
14
15
|
gem.add_development_dependency "yard", ">= 0"
|
|
15
16
|
gem.executables << 'h5-min'
|
data/VERSION
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
0.0
|
|
1
|
+
0.1.0
|
data/bin/h5-min
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<!doctype html><meta charset=utf-8><title>Untitled</title><p><a href=foo&bar>a</a>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<!doctype html><meta charset=utf-8><title>Untitled</title><p><a href=a"b>a</a>
|
data/fixtures/dl.html
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<!doctype html><meta charset=utf-8><title>Untitled</title><dl><dt>Term<dd>Desc<dt>Term<dt>Term<dd>Desc</dl>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<!doctype html><meta charset=utf-8><title>Untitled</title><p>⋔ Ь
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<!doctype html><meta charset=utf-8><title>Untitled</title><p>1 & 2 > ?
|
data/fixtures/ie.html.min
CHANGED
data/fixtures/lists.html
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<!doctype html><meta charset=utf-8><title>Untitled</title><ul><li><i>one</i><li><i>two</i></ul>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<!doctype html><meta charset=utf-8><title>Untitled</title><p><dfn title="a b">d</dfn>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<!doctype html><meta charset=utf-8><title>Untitled</title><p>p<p>p
|
data/fixtures/pre.html.min
CHANGED
data/fixtures/skeleton.html.min
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
<!
|
|
1
|
+
<!doctype html><title>Untitled</title><meta charset=utf-8><link href=//creativecommons.org/licenses/by-sa/3.0/ rel=license><h1>Title</h1><p>Test
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<!doctype html><meta charset=utf-8><title>Untitled</title><p><a class=c href=/ hreflang=az-Latn-x-latn style=s title=t>a</a>
|
data/fixtures/table.html
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<meta charset=utf-8>
|
|
3
|
+
<title>Untitled</title>
|
|
4
|
+
<table class=c>
|
|
5
|
+
<thead class=h>
|
|
6
|
+
<tr>
|
|
7
|
+
<th>H</th>
|
|
8
|
+
<th>H</th>
|
|
9
|
+
</tr>
|
|
10
|
+
</thead>
|
|
11
|
+
<tbody class=b>
|
|
12
|
+
<tr>
|
|
13
|
+
<td>D</td>
|
|
14
|
+
<td>D</td>
|
|
15
|
+
</tr>
|
|
16
|
+
<tr>
|
|
17
|
+
<td>D</td>
|
|
18
|
+
<td>D</td>
|
|
19
|
+
</tr>
|
|
20
|
+
</tbody>
|
|
21
|
+
</table>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<!doctype html><meta charset=utf-8><title>Untitled</title><table class=c><thead class=h><tr><th>H<th>H<tbody class=b><tr><td>D<td>D<tr><td>D<td>D</table>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<!doctype html><meta charset=utf-8><title>Untitled</title><section><p>A <code>b</code> <i>c</i> d <dfn>e <code>f</code> .</dfn></section>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<!doctype html><meta charset=utf-8><title>Untitled</title><p>This is a<code>string</code>.
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
# coding: utf-8
|
|
2
|
+
module HTML5
|
|
3
|
+
module OptionalTags
|
|
4
|
+
# Optional tags as per
|
|
5
|
+
# http://www.whatwg.org/specs/web-apps/current-work/multipage/syntax.html#optional-tags
|
|
6
|
+
OPTIONAL = [
|
|
7
|
+
# An html element's start tag may be omitted if the first thing inside
|
|
8
|
+
# the html element is not a comment.
|
|
9
|
+
%r{<html>},
|
|
10
|
+
# An html element's end tag may be omitted if the html element is not
|
|
11
|
+
# immediately followed by a comment.
|
|
12
|
+
%r{</html>},
|
|
13
|
+
# A head element's start tag may be omitted if the element is empty, or
|
|
14
|
+
# if the first thing inside the head element is an element.
|
|
15
|
+
%r{<head>},
|
|
16
|
+
# A head element's end tag may be omitted if the head element is not
|
|
17
|
+
# immediately followed by a space character or a comment.
|
|
18
|
+
%r{</head>},
|
|
19
|
+
# A body element's start tag may be omitted if the element is empty, or
|
|
20
|
+
# if the first thing inside the body element is not a space character or
|
|
21
|
+
# a comment, except if the first thing inside the body element is a
|
|
22
|
+
# script or style element.
|
|
23
|
+
%r{<body>\s?(?!<(script|style))},
|
|
24
|
+
# A body element's end tag may be omitted if the body element is not
|
|
25
|
+
# immediately followed by a comment.
|
|
26
|
+
%r{</body>},
|
|
27
|
+
# A li element's end tag may be omitted if the li element is immediately
|
|
28
|
+
# followed by another li element or if there is no more content in the
|
|
29
|
+
# parent element.
|
|
30
|
+
%r{</li>\s?(?=(<li|</[uo]l))},
|
|
31
|
+
# A dt element's end tag may be omitted if the dt element is immediately
|
|
32
|
+
# followed by another dt element or a dd element.
|
|
33
|
+
%r{</dt>\s?(?=<d[td])},
|
|
34
|
+
# A dd element's end tag may be omitted if the dd element is immediately
|
|
35
|
+
# followed by another dd element or a dt element, or if there is no more
|
|
36
|
+
# content in the parent element.
|
|
37
|
+
%r{</dd>\s?(?=(<d[dt]|</dl))},
|
|
38
|
+
# A p element's end tag may be omitted if the p element is immediately
|
|
39
|
+
# followed by an address, article, aside, blockquote, dir, div, dl,
|
|
40
|
+
# fieldset, footer, form, h1, h2, h3, h4, h5, h6, header, hgroup, hr,
|
|
41
|
+
# menu, nav, ol, p, pre, section, table, or ul, element, or if there is
|
|
42
|
+
# no more content in the parent element and the parent element is not an
|
|
43
|
+
# a element.
|
|
44
|
+
%r{</p>\s?(?=(<(address|article|aside|blockquote|dir|div|dl|fieldset|footer|
|
|
45
|
+
form|h\d|header|hgroup|hr|menu|nav|ol|p|pre|section|table|ul)|</))}x,
|
|
46
|
+
%r{</p>\s?\Z},
|
|
47
|
+
# An rt element's end tag may be omitted if the rt element is
|
|
48
|
+
# immediately followed by an rt or rp element, or if there is no more
|
|
49
|
+
# content in the parent element.
|
|
50
|
+
%r{</rt>\s?(?=(<r[tp]|</))},
|
|
51
|
+
# An rp element's end tag may be omitted if the rp element is
|
|
52
|
+
# immediately followed by an rt or rp element, or if there is no more
|
|
53
|
+
# content in the parent element.
|
|
54
|
+
%r{</rp>\s?(?=(<r[tp]|</))},
|
|
55
|
+
# An optgroup element's end tag may be omitted if the optgroup element
|
|
56
|
+
# is immediately followed by another optgroup element, or if there is no
|
|
57
|
+
# more content in the parent element.
|
|
58
|
+
%r{</optgroup>\s?(?=(<optgroup|</))},
|
|
59
|
+
# An option element's end tag may be omitted if the option element is
|
|
60
|
+
# immediately followed by another option element, or if it is
|
|
61
|
+
# immediately followed by an optgroup element, or if there is no more
|
|
62
|
+
# content in the parent element.
|
|
63
|
+
%r{</option>\s?(?=(<(option|optgroup)|</))},
|
|
64
|
+
# A colgroup element's start tag may be omitted if the first thing
|
|
65
|
+
# inside the colgroup element is a col element, and if the element is
|
|
66
|
+
# not immediately preceded by another colgroup element whose end tag has
|
|
67
|
+
# been omitted. (It can't be omitted if the element is empty.)
|
|
68
|
+
%r{<colgroup>\s?(?=<col)}, # FIXME: Incomplete
|
|
69
|
+
# A colgroup element's end tag may be omitted if the colgroup element is
|
|
70
|
+
# not immediately followed by a space character or a comment.
|
|
71
|
+
%r{</colgroup>},
|
|
72
|
+
# A thead element's end tag may be omitted if the thead element is
|
|
73
|
+
# immediately followed by a tbody or tfoot element.
|
|
74
|
+
%r{</thead>\s?(?=<t(body|foot))},
|
|
75
|
+
# A tbody element's start tag may be omitted if the first thing inside
|
|
76
|
+
# the tbody element is a tr element, and if the element is not
|
|
77
|
+
# immediately preceded by a tbody, thead, or tfoot element whose end tag
|
|
78
|
+
# has been omitted. (It can't be omitted if the element is empty.)
|
|
79
|
+
%r{(?<=</t(head|body|foot)>)\s?<tbody>\s?(?=<tr)}x, # TODO: Look again
|
|
80
|
+
# A tbody element's end tag may be omitted if the tbody element is
|
|
81
|
+
# immediately followed by a tbody or tfoot element, or if there is no
|
|
82
|
+
# more content in the parent element.
|
|
83
|
+
%r{</tbody>\s?(?=(<t(body|foot)|</))},
|
|
84
|
+
# A tfoot element's end tag may be omitted if the tfoot element is
|
|
85
|
+
# immediately followed by a tbody element, or if there is no more
|
|
86
|
+
# content in the parent element.
|
|
87
|
+
%r{</tfoot>\s?(?=(<tbody|</))},
|
|
88
|
+
# A tr element's end tag may be omitted if the tr element is immediately
|
|
89
|
+
# followed by another tr element, or if there is no more content in the
|
|
90
|
+
# parent element.
|
|
91
|
+
%r{</tr>\s?(?=(<tr|</))},
|
|
92
|
+
%r{</tr>\s?(?=(<t(body|foot|head)))}, # We may have already removed the
|
|
93
|
+
# parent's end tag
|
|
94
|
+
# A td element's end tag may be omitted if the td element is immediately
|
|
95
|
+
# followed by a td or th element, or if there is no more content in the
|
|
96
|
+
# parent element.
|
|
97
|
+
%r{</td>\s?(?=(<t[dhr]|</))},
|
|
98
|
+
# A th element's end tag may be omitted if the th element is immediately
|
|
99
|
+
# followed by a td or th element, or if there is no more content in the
|
|
100
|
+
# parent element.
|
|
101
|
+
%r{</th>\s?(?=(<t[dhr]|</))},
|
|
102
|
+
%r{</th>\s?(?=((<t(body|foot))|</))},
|
|
103
|
+
|
|
104
|
+
#However, a start tag must never be omitted if it has any attributes.
|
|
105
|
+
|
|
106
|
+
# The following are void elements
|
|
107
|
+
# (http://www.whatwg.org/specs/web-apps/current-work/multipage/syntax.html#void-elements)
|
|
108
|
+
# Therefore, their end tag must always be omitted
|
|
109
|
+
%r{</area},
|
|
110
|
+
%r{</base>},
|
|
111
|
+
%r{</br>},
|
|
112
|
+
%r{</col>},
|
|
113
|
+
%r{</command>},
|
|
114
|
+
%r{</embed>},
|
|
115
|
+
%r{</hr>},
|
|
116
|
+
%r{</img>},
|
|
117
|
+
%r{</input>},
|
|
118
|
+
%r{</keygen>},
|
|
119
|
+
%r{</link>},
|
|
120
|
+
%r{</meta>},
|
|
121
|
+
%r{</param>},
|
|
122
|
+
%r{</source>},
|
|
123
|
+
%r{</track>},
|
|
124
|
+
%r{</wbr>},
|
|
125
|
+
]
|
|
126
|
+
|
|
127
|
+
def self.remove html
|
|
128
|
+
OPTIONAL.each do |regex|
|
|
129
|
+
html.gsub!(/#{regex}/i, '')
|
|
130
|
+
end
|
|
131
|
+
html
|
|
132
|
+
end
|
|
133
|
+
end
|
|
134
|
+
end
|
data/lib/h5-min.rb
CHANGED
|
@@ -1,88 +1,126 @@
|
|
|
1
1
|
require 'nokogiri'
|
|
2
|
-
require '
|
|
2
|
+
require 'htmlentities'
|
|
3
|
+
require_relative 'h5-min/optional'
|
|
3
4
|
|
|
4
5
|
module HTML5
|
|
5
|
-
|
|
6
|
-
|
|
6
|
+
# Elements in which whitespace is significant, so can't be normalised
|
|
7
|
+
PRE_TAGS = [:pre, :style, :script, :textarea]
|
|
8
|
+
|
|
9
|
+
# Elements representing flow content
|
|
10
|
+
FLOW_ELEMENTS = %w{a abbr address area article aside audio b bdo blockquote br
|
|
11
|
+
button canvas cite code command datalist del details dfn div
|
|
12
|
+
dl em embed fieldset figure footer form h1 h2 h3 h4 h5 h6 header
|
|
13
|
+
hgroup hr i iframe img input ins kbd keygen label link
|
|
14
|
+
map mark math menu meta meter nav noscript object ol output
|
|
15
|
+
p pre progress q ruby samp script section select small span
|
|
16
|
+
strong style sub sup svg table textarea time ul var video wbr
|
|
17
|
+
}.map(&:to_sym)
|
|
7
18
|
|
|
8
|
-
|
|
9
|
-
OMIT_TAGS = [:html, :body, :head]
|
|
19
|
+
@minifier ||= Class.new(Nokogiri::XML::SAX::Document) do
|
|
10
20
|
|
|
11
|
-
|
|
12
|
-
OMIT_END_TAGS = [:link, :meta, :img, :br]
|
|
13
|
-
|
|
14
|
-
# Elements in which whitespace is significant, so can't be normalised
|
|
15
|
-
PRE_TAGS = [:pre]
|
|
16
|
-
|
|
17
|
-
def self.minify html
|
|
18
|
-
minifier = new
|
|
19
|
-
Nokogiri::HTML::SAX::Parser.new(minifier).parse(html)
|
|
20
|
-
minifier.buf.strip
|
|
21
|
-
end
|
|
21
|
+
attr_accessor :in_pre, :buf, :text_node, :entities
|
|
22
22
|
|
|
23
23
|
def initialize
|
|
24
24
|
@in_pre = false
|
|
25
|
-
@buf = ''
|
|
25
|
+
@buf, @text_node = '', ''
|
|
26
|
+
@stack = []
|
|
27
|
+
@entities = HTMLEntities.new :expanded
|
|
26
28
|
end
|
|
27
29
|
|
|
28
30
|
# HTML5 documents begin with the doctype
|
|
29
31
|
def start_document
|
|
30
|
-
buf << "<!
|
|
32
|
+
buf << "<!doctype html>"
|
|
31
33
|
end
|
|
32
34
|
|
|
33
35
|
def start_element name, attrs = []
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
name + '=' + format_attribute_value(value)
|
|
40
|
-
end
|
|
41
|
-
self.in_pre = true if PRE_TAGS.include?(name.to_sym)
|
|
42
|
-
buf.rstrip! unless in_pre
|
|
43
|
-
buf << "<#{name}" + (attrs.empty? ? '' : ' ' + attrs.join(' ')) + ">"
|
|
36
|
+
name = normalise_name name
|
|
37
|
+
dump_text_node
|
|
38
|
+
@stack.push name
|
|
39
|
+
self.in_pre = true if PRE_TAGS.include?(name)
|
|
40
|
+
buf << "<#{name}" + format_attributes(attrs) + ">"
|
|
44
41
|
end
|
|
45
42
|
|
|
46
43
|
def end_element name
|
|
47
|
-
|
|
48
|
-
|
|
44
|
+
name = normalise_name name
|
|
45
|
+
dump_text_node
|
|
46
|
+
@stack.pop
|
|
47
|
+
buf.rstrip! unless in_pre
|
|
48
|
+
self.in_pre = PRE_TAGS.include?(name)
|
|
49
49
|
buf << "</#{name}>"
|
|
50
50
|
end
|
|
51
51
|
|
|
52
|
-
def comment
|
|
52
|
+
def comment string
|
|
53
53
|
# I.E "conditional comments" should be retained as-is
|
|
54
54
|
if string =~ /\[if\s+lt\s+IE\s+\d+\]/i
|
|
55
55
|
buf << "<!--#{string}-->"
|
|
56
56
|
end
|
|
57
57
|
end
|
|
58
58
|
|
|
59
|
-
def cdata_block
|
|
59
|
+
def cdata_block string
|
|
60
60
|
buf << string
|
|
61
61
|
end
|
|
62
62
|
|
|
63
|
-
def characters
|
|
64
|
-
|
|
65
|
-
if in_pre
|
|
66
|
-
buf << chars
|
|
67
|
-
else
|
|
68
|
-
buf << chars.gsub(/[\n\t]/, '').squeeze(' ')
|
|
69
|
-
end
|
|
63
|
+
def characters chars
|
|
64
|
+
text_node << chars
|
|
70
65
|
end
|
|
71
66
|
|
|
72
67
|
private
|
|
73
|
-
def format_attribute_value
|
|
74
|
-
value = value
|
|
68
|
+
def format_attribute_value value
|
|
69
|
+
value = format_entities value
|
|
75
70
|
value_needs_quoting?(value) ? %Q{"#{value}"} : value
|
|
76
71
|
end
|
|
77
72
|
|
|
78
|
-
def
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
73
|
+
def normalise_name name
|
|
74
|
+
name.downcase.to_sym
|
|
75
|
+
end
|
|
76
|
+
|
|
77
|
+
def format_attributes attrs
|
|
78
|
+
return '' if attrs.empty?
|
|
79
|
+
Hash[*attrs].map do |name, value|
|
|
80
|
+
[normalise_name(name), format_attribute_value(value)]
|
|
81
|
+
end.sort_by do |name, value|
|
|
82
|
+
name
|
|
83
|
+
end.map do |name, value|
|
|
84
|
+
"#{name}=#{value}"
|
|
85
|
+
end.join(' ').insert(0, ' ')
|
|
86
86
|
end
|
|
87
|
+
|
|
88
|
+
# Can the given value be legally unquoted as per
|
|
89
|
+
# http://www.whatwg.org/specs/web-apps/current-work/multipage/syntax.html#attributes-0
|
|
90
|
+
# ?
|
|
91
|
+
def value_needs_quoting? value
|
|
92
|
+
# must not contain any " ", """, "'", ">", or "=", characters
|
|
93
|
+
value =~ /[[:space:]"'><=`]/ or value.empty?
|
|
94
|
+
end
|
|
95
|
+
|
|
96
|
+
def format_entities html
|
|
97
|
+
entities.encode(entities.decode(html), :basic)
|
|
98
|
+
end
|
|
99
|
+
|
|
100
|
+
def format_text_node
|
|
101
|
+
text = format_entities text_node
|
|
102
|
+
return text if in_pre
|
|
103
|
+
text.gsub!(/[\n\t]/,'')
|
|
104
|
+
# Don't strip inter-element white space for flow elements
|
|
105
|
+
unless buf =~ %r{</\w+>\s*\Z} and in_flow_element?
|
|
106
|
+
text.lstrip!
|
|
107
|
+
end
|
|
108
|
+
text.squeeze(' ')
|
|
109
|
+
end
|
|
110
|
+
|
|
111
|
+
def in_flow_element?
|
|
112
|
+
not (FLOW_ELEMENTS & @stack).empty?
|
|
113
|
+
end
|
|
114
|
+
|
|
115
|
+
def dump_text_node
|
|
116
|
+
buf << format_text_node
|
|
117
|
+
text_node.clear
|
|
118
|
+
end
|
|
119
|
+
end
|
|
120
|
+
|
|
121
|
+
def self.minify html
|
|
122
|
+
minifier = @minifier.new
|
|
123
|
+
Nokogiri::HTML::SAX::Parser.new(minifier).parse(html)
|
|
124
|
+
OptionalTags.remove minifier.buf.strip
|
|
87
125
|
end
|
|
88
126
|
end
|
data/spec/h5-min_spec.rb
CHANGED
|
@@ -2,22 +2,33 @@ require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
|
|
|
2
2
|
|
|
3
3
|
def minify(source)
|
|
4
4
|
source = 'fixtures/' + source
|
|
5
|
-
[HTML5
|
|
5
|
+
[HTML5.minify(File.read source), File.read(source + '.min').chomp]
|
|
6
6
|
end
|
|
7
7
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
8
|
+
SPECS = {
|
|
9
|
+
skeleton: "can minify a skeleton HTML document",
|
|
10
|
+
pre: "doesn't collpase whitespace inside <pre> tags",
|
|
11
|
+
whitespace_p: "collpases whitespace inside <p> tags",
|
|
12
|
+
whitespace_complex: "collpases complex whitespace inside <p> tags",
|
|
13
|
+
lists: "collpases whitespace inside lists",
|
|
14
|
+
ie: "doesn't remove I.E conditional comments",
|
|
15
|
+
table: "removes optional elements in tables",
|
|
16
|
+
dl: "removes optional elements in definition lists",
|
|
17
|
+
normalise_tag_name: "normalises case of element names",
|
|
18
|
+
normalise_attribute_name: "normalises case of attribute names",
|
|
19
|
+
entities_no_expand: "doesn't decode unsafe HTML entities",
|
|
20
|
+
pre_entities: "doesn't decode unsafe HTML entities in preformatted elements",
|
|
21
|
+
attribute_value_ampersand: "doesn't decode ampersand entity in attribute values",
|
|
22
|
+
attribute_value_quot: "encodes quotation marks in attribute values",
|
|
23
|
+
entities_expand: "decodes safe HTML entities",
|
|
24
|
+
sort_attributes: "sorts attribute names alphabetically",
|
|
25
|
+
}
|
|
18
26
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
27
|
+
describe HTML5, '.minify' do
|
|
28
|
+
SPECS.each do |fix, desc|
|
|
29
|
+
it desc do
|
|
30
|
+
source, target = minify("#{fix.to_s.tr(?_, ?-)}.html")
|
|
31
|
+
source.to_s.should == target
|
|
32
|
+
end
|
|
22
33
|
end
|
|
23
34
|
end
|
metadata
CHANGED
|
@@ -4,9 +4,9 @@ version: !ruby/object:Gem::Version
|
|
|
4
4
|
prerelease: false
|
|
5
5
|
segments:
|
|
6
6
|
- 0
|
|
7
|
-
- 0
|
|
8
7
|
- 1
|
|
9
|
-
|
|
8
|
+
- 0
|
|
9
|
+
version: 0.1.0
|
|
10
10
|
platform: ruby
|
|
11
11
|
authors:
|
|
12
12
|
- Run Paint Run Run
|
|
@@ -14,13 +14,28 @@ autorequire:
|
|
|
14
14
|
bindir: bin
|
|
15
15
|
cert_chain: []
|
|
16
16
|
|
|
17
|
-
date: 2010-07-
|
|
17
|
+
date: 2010-07-09 00:00:00 +01:00
|
|
18
18
|
default_executable:
|
|
19
19
|
dependencies:
|
|
20
20
|
- !ruby/object:Gem::Dependency
|
|
21
|
-
name:
|
|
21
|
+
name: htmlentities
|
|
22
22
|
prerelease: false
|
|
23
23
|
requirement: &id001 !ruby/object:Gem::Requirement
|
|
24
|
+
none: false
|
|
25
|
+
requirements:
|
|
26
|
+
- - ">="
|
|
27
|
+
- !ruby/object:Gem::Version
|
|
28
|
+
segments:
|
|
29
|
+
- 4
|
|
30
|
+
- 1
|
|
31
|
+
- 0
|
|
32
|
+
version: 4.1.0
|
|
33
|
+
type: :runtime
|
|
34
|
+
version_requirements: *id001
|
|
35
|
+
- !ruby/object:Gem::Dependency
|
|
36
|
+
name: rspec
|
|
37
|
+
prerelease: false
|
|
38
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
|
24
39
|
none: false
|
|
25
40
|
requirements:
|
|
26
41
|
- - ">="
|
|
@@ -31,11 +46,11 @@ dependencies:
|
|
|
31
46
|
- 9
|
|
32
47
|
version: 1.2.9
|
|
33
48
|
type: :development
|
|
34
|
-
version_requirements: *
|
|
49
|
+
version_requirements: *id002
|
|
35
50
|
- !ruby/object:Gem::Dependency
|
|
36
51
|
name: yard
|
|
37
52
|
prerelease: false
|
|
38
|
-
requirement: &
|
|
53
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
|
39
54
|
none: false
|
|
40
55
|
requirements:
|
|
41
56
|
- - ">="
|
|
@@ -44,7 +59,7 @@ dependencies:
|
|
|
44
59
|
- 0
|
|
45
60
|
version: "0"
|
|
46
61
|
type: :development
|
|
47
|
-
version_requirements: *
|
|
62
|
+
version_requirements: *id003
|
|
48
63
|
description: Trivial command-line minifier for HTML5 markup
|
|
49
64
|
email: runrun@runpaint.org
|
|
50
65
|
executables:
|
|
@@ -63,13 +78,40 @@ files:
|
|
|
63
78
|
- Rakefile
|
|
64
79
|
- VERSION
|
|
65
80
|
- bin/h5-min
|
|
81
|
+
- fixtures/attribute-value-ampersand.html
|
|
82
|
+
- fixtures/attribute-value-ampersand.html.min
|
|
83
|
+
- fixtures/attribute-value-quot.html
|
|
84
|
+
- fixtures/attribute-value-quot.html.min
|
|
85
|
+
- fixtures/dl.html
|
|
86
|
+
- fixtures/dl.html.min
|
|
87
|
+
- fixtures/entities-expand.html
|
|
88
|
+
- fixtures/entities-expand.html.min
|
|
89
|
+
- fixtures/entities-no-expand.html
|
|
90
|
+
- fixtures/entities-no-expand.html.min
|
|
66
91
|
- fixtures/ie.html
|
|
67
92
|
- fixtures/ie.html.min
|
|
93
|
+
- fixtures/lists.html
|
|
94
|
+
- fixtures/lists.html.min
|
|
95
|
+
- fixtures/normalise-attribute-name.html
|
|
96
|
+
- fixtures/normalise-attribute-name.html.min
|
|
97
|
+
- fixtures/normalise-tag-name.html
|
|
98
|
+
- fixtures/normalise-tag-name.html.min
|
|
99
|
+
- fixtures/pre-entities.html
|
|
100
|
+
- fixtures/pre-entities.html.min
|
|
68
101
|
- fixtures/pre.html
|
|
69
102
|
- fixtures/pre.html.min
|
|
70
103
|
- fixtures/skeleton.html
|
|
71
104
|
- fixtures/skeleton.html.min
|
|
105
|
+
- fixtures/sort-attributes.html
|
|
106
|
+
- fixtures/sort-attributes.html.min
|
|
107
|
+
- fixtures/table.html
|
|
108
|
+
- fixtures/table.html.min
|
|
109
|
+
- fixtures/whitespace-complex.html
|
|
110
|
+
- fixtures/whitespace-complex.html.min
|
|
111
|
+
- fixtures/whitespace-p.html
|
|
112
|
+
- fixtures/whitespace-p.html.min
|
|
72
113
|
- lib/h5-min.rb
|
|
114
|
+
- lib/h5-min/optional.rb
|
|
73
115
|
- spec/h5-min_spec.rb
|
|
74
116
|
- spec/spec.opts
|
|
75
117
|
- spec/spec_helper.rb
|