HTML Tidy package for Ruby

K

Kevin Howe

My experiments with Ruby's DL module have led me to create
a Ruby wrapper/interface for HTML Tidy (http://tidy.sf.net).
I'm hoping to get some feedback on it since I'm new to Ruby/DL
and am not able to test on *nix systems at the moment.

Usage:

require 'tidy'
html = '<html><title>title</title>Body</html>'
xml = Tidy.open:)show_warnings=>true) do |tidy|
tidy.options.output_xml = true
puts tidy.options.show_warnings
xml = tidy.clean(html)
puts tidy.errors
puts tidy.diagnostics
xml
end
puts xml

Package:

http://www.newclear.ca/ruby/tidy/
http://www.newclear.ca/ruby/tidy/apidoc/

Requires a compiled tidy library named "tidylib.so" in your require path.
Libraries can be found on http://tidy.sf.net
Tests done using tidy-dll-fast (http://dev.int64.org/tidy.html) on Win2kPro
 
K

Kevin Howe

I've uploaded B2. The B1 version hardcoded the library name to "tidylib.so".
B2 introduces a load() function which specifies the path to the library:

require 'tidy'
Tidy.load('path/to/tidylib.so')

This avoids the hard coding of the name. Ideally I'll then be adding some
auto-detection which will search the RUBYLIB/RUBYPATH/PATH directories for
files named (tidy|tidylib|libtidy).(dll|so) etc. so that in the end no one
will ever have call this function in their scripts.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,770
Messages
2,569,584
Members
45,075
Latest member
MakersCBDBloodSupport

Latest Threads

Top