html_pretty 0.1.0 → 0.1.1

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 CHANGED
@@ -1,25 +1,46 @@
1
- require 'rexml/document'
2
1
 
3
2
 
4
- task :compare do
5
- dstdir = 'compare'
6
- srcfile = "#{dstdir}/_orig.html"
7
- srcstr = IO.read(srcfile)
3
+ namespace :output do
4
+ def work_dir
5
+ 'compare'
6
+ end
8
7
 
9
- `ruby -Ilib bin/html_pretty #{srcfile} >#{dstdir}/html_pretty.html`
10
- `htmlbeautifier <#{srcfile} >#{dstdir}/htmlbeautifier.html`
11
- `tidy -i -q #{srcfile} >#{dstdir}/tidy.html 2>&-`
8
+ def src_file
9
+ "#{work_dir}/_orig.html"
10
+ end
12
11
 
13
- begin
14
- require 'nokogiri'
15
- doc = Nokogiri::XML(srcstr, &:noblanks)
16
- File.open("#{dstdir}/nokogiri.html", 'w'){|f| f.write doc.to_xhtml(:indent => 2)}
17
- rescue LoadError => e
18
- $stderr.puts '-- nokogiri not found -- skipping'
12
+ def orig_str
13
+ IO.read(orig_file)
14
+ end
15
+
16
+ def dst_file(t)
17
+ "#{work_dir}/#{t.rpartition(':').last}.html"
18
+ end
19
+
20
+ task :html_pretty do |t|
21
+ sh "ruby -Ilib bin/html_pretty #{orig_file} >#{dst_file(t)}"
19
22
  end
20
23
 
21
- doc = REXML::Document.new(srcstr)
22
- File.open("#{dstdir}/rexml.html", 'w'){|f| doc.write f, 2}
24
+ task :htmlbeautifier do |t|
25
+ sh "htmlbeautifier <#{orig_file} >#{dst_file(t)}"
26
+ end
27
+
28
+ task :tidy do |t|
29
+ sh "tidy -i -q #{orig_file} >#{dst_file(t)} 2>&1"
30
+ end
31
+
32
+ task :rexml do |t|
33
+ require 'rexml/document'
34
+ doc = REXML::Document.new(orig_str)
35
+ File.open(dst_file(t), 'w'){|f| doc.write f, 2}
36
+ end
37
+
38
+ task :nokogiri do |t|
39
+ require 'nokogiri'
40
+ doc = Nokogiri::XML(orig_str, &:noblanks)
41
+ File.open(dst_file(t), 'w'){|f| f.write doc.to_xhtml(:indent => 2)}
42
+ end
23
43
  end
44
+ task :output => 'output:html_pretty'
24
45
 
25
- task :default => :compare
46
+ task :default => :output
data/lib/html_pretty.rb CHANGED
@@ -2,7 +2,7 @@ require 'html_pretty/version'
2
2
 
3
3
 
4
4
  module HtmlPretty
5
- SPECIAL = /(<!--.*?-->|<script.*?\/script>|<style.*?\/style>)/m
5
+ SPECIAL = /(<!DOCTYPE.*?>|<!--.*?-->|<script.*?\/script>|<style.*?\/style>)/m
6
6
 
7
7
  # Really bad assumption heavy tidy...
8
8
  # Self rolled because other versions have weird errors
@@ -1,3 +1,3 @@
1
1
  module HtmlPretty
2
- VERSION = '0.1.0'
2
+ VERSION = '0.1.1'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: html_pretty
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
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: 2013-01-23 00:00:00.000000000 Z
12
+ date: 2013-01-24 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rspec