Module: Tidy
- Defined in:
- lib/tidy.rb
Overview
Ruby interface to HTML Tidy Library Project (tidy.sf.net)
Usage
$TIDYLIB = '/usr/lib/tidylib.so'
require 'rubygems'
require_gem 'tidy'
html = '<html><title>title</title>Body</html>'
xml = Tidy.open(:show_warnings=>true) do |tidy|
tidy..output_xml = true
puts tidy..show_warnings
xml = tidy.clean(html)
puts tidy.errors
puts tidy.diagnostics
xml
end
puts xml
- Author
-
Kevin Howe
- License
-
Distributes under the same terms as Ruby
Class Method Summary collapse
-
.new(options = nil) ⇒ Object
Return a Tidyobj instance.
-
.open(options = nil) ⇒ Object
With no block, open is a synonym for Tidy.new .
-
.to_b(value) ⇒ Object
Convert to boolean.
Class Method Details
.new(options = nil) ⇒ Object
Return a Tidyobj instance
36 37 38 |
# File 'lib/tidy.rb', line 36 def new(=nil) Tidyobj.new() end |
.open(options = nil) ⇒ Object
With no block, open is a synonym for Tidy.new . If a block is present, it is passed aTidy as a parameter. aTidyObj.release is ensured at end of the block
44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/tidy.rb', line 44 def open(=nil) tidy = Tidy.new() if block_given? begin yield tidy ensure tidy.release end else tidy end end |
.to_b(value) ⇒ Object
Convert to boolean. 0, false and nil return false, anything else true
60 61 62 63 |
# File 'lib/tidy.rb', line 60 def to_b(value) return false if [0,false,nil].include?(value) true end |