html5small 0.1.0 → 0.2.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/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
1
+ 0.2.0
data/bin/html5small CHANGED
@@ -1,3 +1,3 @@
1
1
  #!/usr/bin/env ruby
2
2
  require_relative '../lib/html5small'
3
- print HTML5.minify ARGF.read
3
+ print HTML5small.minify ARGF.read
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.1.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-11-04"
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/Minifier.rb",
72
- "lib/html5small/OptionalTags.rb",
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/Minifier'
2
- require_relative 'html5small/OptionalTags'
1
+ require_relative 'html5small/minifier'
2
+ require_relative 'html5small/optional_tags'
3
3
 
4
- module HTML5
4
+ module HTML5small
5
5
  def self.minify html
6
- minifier = HTML5::Minifier.new
6
+ minifier = Minifier.new
7
7
  Nokogiri::HTML::SAX::Parser.new(minifier).parse(html)
8
8
  OptionalTags.remove minifier.buf.strip
9
9
  end
@@ -1,7 +1,7 @@
1
1
  require 'nokogiri'
2
2
  require 'htmlentities'
3
3
 
4
- module HTML5
4
+ module HTML5small
5
5
  class Minifier < Nokogiri::XML::SAX::Document
6
6
  # Elements in which whitespace is significant, so can't be normalised
7
7
  PRE_TAGS = [:pre, :style, :script, :textarea]
@@ -0,0 +1,12 @@
1
+ require 'html5small'
2
+ require 'nanoc'
3
+
4
+ module HTML5small
5
+ class NanocFilter < ::Nanoc::Filter
6
+ identifier :html5small
7
+
8
+ def run(content, params = {})
9
+ HTML5small::minify content
10
+ end
11
+ end
12
+ end
@@ -1,5 +1,5 @@
1
1
  # coding: utf-8
2
- module HTML5
2
+ module HTML5small
3
3
  module OptionalTags
4
4
  # Optional tags as per
5
5
  # http://www.whatwg.org/specs/web-apps/current-work/multipage/syntax.html#optional-tags
@@ -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
- [HTML5.minify(File.read source), File.read(source + '.min').chomp]
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 HTML5, '.minify' do
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.1.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-11-04 00:00:00.000000000 Z
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/Minifier.rb
139
- - lib/html5small/OptionalTags.rb
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