html5small 0.1.0 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +16 -0
- data/VERSION +1 -1
- data/bin/html5small +1 -1
- data/html5small.gemspec +5 -4
- data/lib/html5small.rb +4 -4
- data/lib/html5small/{Minifier.rb → minifier.rb} +1 -1
- data/lib/html5small/nanoc.rb +12 -0
- data/lib/html5small/{OptionalTags.rb → optional_tags.rb} +1 -1
- data/spec/htmlsmall_spec.rb +2 -2
- metadata +5 -4
data/README.md
CHANGED
@@ -16,6 +16,22 @@ require 'html5small'
|
|
16
16
|
::HTML5.minify '<html>...</html>'
|
17
17
|
```
|
18
18
|
|
19
|
+
### As a nanoc filter
|
20
|
+
HTML5small can also be used as a [nanoc](http://nanoc.stoneship.org/) [filter](http://nanoc.stoneship.org/docs/4-basic-concepts/#filters).
|
21
|
+
This will lead to even faster loading if your compiled sites.
|
22
|
+
|
23
|
+
To use the HTML5small filter, add this line to your `lib/helpers.rb`:
|
24
|
+
```ruby
|
25
|
+
require 'html5small/nanoc'
|
26
|
+
```
|
27
|
+
Then adapt your `Rules` to apply the filter where necessary. For example:
|
28
|
+
```ruby
|
29
|
+
compile '/blog/*/' do
|
30
|
+
filter :erb
|
31
|
+
filter :html5small
|
32
|
+
end
|
33
|
+
```
|
34
|
+
|
19
35
|
## Origin
|
20
36
|
HTML5small is based on [h5-min](https://github.com/runpaint/h5-min),
|
21
37
|
which is currently [unmaintained](https://github.com/runpaint/h5-min/issues).
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.2.0
|
data/bin/html5small
CHANGED
data/html5small.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = "html5small"
|
8
|
-
s.version = "0.
|
8
|
+
s.version = "0.2.0"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Run Paint Run Run", "Ruben Verborgh"]
|
12
|
-
s.date = "2012-
|
12
|
+
s.date = "2012-12-02"
|
13
13
|
s.description = "Minifier for HTML5 documents"
|
14
14
|
s.email = "ruben.verborgh@gmail.com"
|
15
15
|
s.executables = ["html5small", "html5small"]
|
@@ -68,8 +68,9 @@ Gem::Specification.new do |s|
|
|
68
68
|
"fixtures/whitespace-p.html.min",
|
69
69
|
"html5small.gemspec",
|
70
70
|
"lib/html5small.rb",
|
71
|
-
"lib/html5small/
|
72
|
-
"lib/html5small/
|
71
|
+
"lib/html5small/minifier.rb",
|
72
|
+
"lib/html5small/nanoc.rb",
|
73
|
+
"lib/html5small/optional_tags.rb",
|
73
74
|
"spec/htmlsmall_spec.rb",
|
74
75
|
"spec/spec.opts",
|
75
76
|
"spec/spec_helper.rb"
|
data/lib/html5small.rb
CHANGED
@@ -1,9 +1,9 @@
|
|
1
|
-
require_relative 'html5small/
|
2
|
-
require_relative 'html5small/
|
1
|
+
require_relative 'html5small/minifier'
|
2
|
+
require_relative 'html5small/optional_tags'
|
3
3
|
|
4
|
-
module
|
4
|
+
module HTML5small
|
5
5
|
def self.minify html
|
6
|
-
minifier =
|
6
|
+
minifier = Minifier.new
|
7
7
|
Nokogiri::HTML::SAX::Parser.new(minifier).parse(html)
|
8
8
|
OptionalTags.remove minifier.buf.strip
|
9
9
|
end
|
data/spec/htmlsmall_spec.rb
CHANGED
@@ -2,7 +2,7 @@ require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
|
|
2
2
|
|
3
3
|
def minify(source)
|
4
4
|
source = 'fixtures/' + source
|
5
|
-
[
|
5
|
+
[HTML5small.minify(File.read source), File.read(source + '.min').chomp]
|
6
6
|
end
|
7
7
|
|
8
8
|
SPECS = {
|
@@ -29,7 +29,7 @@ end
|
|
29
29
|
scripts: "should not escape entities inside scripts",
|
30
30
|
}
|
31
31
|
|
32
|
-
describe
|
32
|
+
describe HTML5small, '.minify' do
|
33
33
|
SPECS.each do |fix, desc|
|
34
34
|
it desc do
|
35
35
|
source, target = minify("#{fix.to_s.tr(?_, ?-)}.html")
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: html5small
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2012-
|
13
|
+
date: 2012-12-02 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: htmlentities
|
@@ -135,8 +135,9 @@ files:
|
|
135
135
|
- fixtures/whitespace-p.html.min
|
136
136
|
- html5small.gemspec
|
137
137
|
- lib/html5small.rb
|
138
|
-
- lib/html5small/
|
139
|
-
- lib/html5small/
|
138
|
+
- lib/html5small/minifier.rb
|
139
|
+
- lib/html5small/nanoc.rb
|
140
|
+
- lib/html5small/optional_tags.rb
|
140
141
|
- spec/htmlsmall_spec.rb
|
141
142
|
- spec/spec.opts
|
142
143
|
- spec/spec_helper.rb
|