html_press 0.0.3 → 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
data/Readme.md CHANGED
@@ -88,4 +88,3 @@ bundle exec jekyll
88
88
  - Support other minifiers (Closure, YUI compressor)
89
89
  - htmlTydi
90
90
  - add examples of usage with Sinatra and Rails
91
-
@@ -25,4 +25,5 @@ Gem::Specification.new do |s|
25
25
 
26
26
  s.add_runtime_dependency "rainpress"
27
27
  s.add_runtime_dependency "uglifier"
28
+ s.add_runtime_dependency "htmlentities"
28
29
  end
@@ -1,6 +1,7 @@
1
1
  require "html_press/version"
2
2
  require "html_press/rainpress"
3
3
  require "html_press/uglifier"
4
+ require "html_press/html_entities"
4
5
  require "html_press/html"
5
6
 
6
7
  module HtmlPress
@@ -59,6 +59,13 @@ module HtmlPress
59
59
  ''
60
60
  end
61
61
 
62
+ # replace entities
63
+ out.gsub! /<|<|>|>|&|&/ do |m|
64
+ reserve m
65
+ end
66
+
67
+ out = HtmlPress.entities_compressor out
68
+
62
69
  # replace PREs with placeholders
63
70
  out.gsub! /\s*(<pre\b[^>]*?>[\s\S]*?<\/pre>)\s*/i do |m|
64
71
  pre = m.gsub(/\s*<pre\b[^>]*?>([\s\S]*?)<\/pre>\s*/i, "\\1")
@@ -0,0 +1,12 @@
1
+ module HtmlPress
2
+ begin
3
+ require 'htmlentities'
4
+ def self.entities_compressor (text)
5
+ HTMLEntities.new.decode(text)
6
+ end
7
+ rescue LoadError => e
8
+ def self.entities_compressor (text)
9
+ text
10
+ end
11
+ end
12
+ end
@@ -1,3 +1,3 @@
1
1
  module HtmlPress
2
- VERSION = "0.0.3"
2
+ VERSION = "0.0.4"
3
3
  end
@@ -172,6 +172,11 @@ describe HtmlPress do
172
172
  # input value "" ?
173
173
  end
174
174
 
175
+ it "should convert html entities to utf-8 symbols" do
176
+ HtmlPress.compress("&lt; &#60; &gt; &#62; &amp; &#38;").should eql "&lt; &#60; &gt; &#62; &amp; &#38;"
177
+ HtmlPress.compress("&eacute;lan").should eql "élan"
178
+ end
179
+
175
180
  # it "should compress javascript in event attributes" do
176
181
  # # javascript: - remove
177
182
  # # onfocus
@@ -192,9 +197,5 @@ describe HtmlPress do
192
197
  #
193
198
  # it "should remove unnecessary quotes for attributes values" do
194
199
  # end
195
- #
196
- # it "should convert html entities to utf-8 symbols" do
197
- # # except <>&
198
- # end
199
200
 
200
201
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: html_press
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-02-05 00:00:00.000000000Z
12
+ date: 2012-02-07 00:00:00.000000000Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rspec
16
- requirement: &26078568 !ruby/object:Gem::Requirement
16
+ requirement: &25710912 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: '0'
22
22
  type: :development
23
23
  prerelease: false
24
- version_requirements: *26078568
24
+ version_requirements: *25710912
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: rake
27
- requirement: &26078208 !ruby/object:Gem::Requirement
27
+ requirement: &25710636 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ! '>='
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: '0'
33
33
  type: :development
34
34
  prerelease: false
35
- version_requirements: *26078208
35
+ version_requirements: *25710636
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: rainpress
38
- requirement: &26077776 !ruby/object:Gem::Requirement
38
+ requirement: &25710348 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ! '>='
@@ -43,10 +43,10 @@ dependencies:
43
43
  version: '0'
44
44
  type: :runtime
45
45
  prerelease: false
46
- version_requirements: *26077776
46
+ version_requirements: *25710348
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: uglifier
49
- requirement: &26077452 !ruby/object:Gem::Requirement
49
+ requirement: &25710036 !ruby/object:Gem::Requirement
50
50
  none: false
51
51
  requirements:
52
52
  - - ! '>='
@@ -54,7 +54,18 @@ dependencies:
54
54
  version: '0'
55
55
  type: :runtime
56
56
  prerelease: false
57
- version_requirements: *26077452
57
+ version_requirements: *25710036
58
+ - !ruby/object:Gem::Dependency
59
+ name: htmlentities
60
+ requirement: &25709748 !ruby/object:Gem::Requirement
61
+ none: false
62
+ requirements:
63
+ - - ! '>='
64
+ - !ruby/object:Gem::Version
65
+ version: '0'
66
+ type: :runtime
67
+ prerelease: false
68
+ version_requirements: *25709748
58
69
  description: Ruby gem for compressing html
59
70
  email:
60
71
  - stereobooster@gmail.com
@@ -69,6 +80,7 @@ files:
69
80
  - html_press.gemspec
70
81
  - lib/html_press.rb
71
82
  - lib/html_press/html.rb
83
+ - lib/html_press/html_entities.rb
72
84
  - lib/html_press/rainpress.rb
73
85
  - lib/html_press/uglifier.rb
74
86
  - lib/html_press/version.rb