I love tidy. I need tidy. What I really really want is a simple wrapper around tidy that will let me use it through Python.
It's not that the current set of wrappers are bad, it's just that they didn't meet my target requirements. What are my target requirements?
- Easy to build, well not necessarily easy, but not a lot of dependecies, nothing beyond Python, TidyLib, and maybe SWIG.
- Easy to install (either a good 'make install', or just a couple files to copy into my project.)
- Easy to call, this is what I want my end Python to look like:
import pytidy
xhtml = pytidy.fix("just same <b>malformed HTML<br/> stuff")
That's it, just a single fucntion that takes in poor markup and then returns well-formed XHTML as output.
Introducing pyTidy
Download pyTidy, a simple Python wrapper of TidyLib that has just the minimal interface described above.
Build Instructions:
- Install SWIG
- Install Tidy
- Edit the variables at the top of the Makefile to
reflect your current environment.
- TOP
- Set to the 'Examples' directory of your SWIG installation.
- INCLUDES
- Change to point to the include directory for your TidyLib install.
- LIBS
- Change to the full path of libtidy.a (libtidy.lib on Windows).
Type 'make' to build. This will build two files:
pytidy.so
(or_pytidy.dll
on Windows) andpytidy.py
Copy both of these files into your project, or the right location in your Python libraries.
Release Notes
Version 0.1 - Initial Release. Currently untested on Windows.
Notes
Yes, I would like to automate this whole process using distutils, but that will have to wait for a later release.
I had avoided mxTidy as it looked like it was a fork of the original command line only Tidy.
Posted by Joe on 2003-11-26
Posted by Yay on 2003-12-05
No, as of right now it is a single function that is hard coded to convert HTML into XHTML. If you'd like to extend the current binding to allow for options please feel free to do so. I'll also accept patches for a future release.
Posted by Joe on 2003-12-05
There is also
http://utidylib.sourceforge.net/
Which uses ctypes, so it's dead easy to use on windows.
Posted by icepick on 2004-04-16
Posted by doug ransom on 2004-07-01
i need help converting any html to well formed xml in a server side .NET script.
can u help me? or direct me to a place where i can find what i am looking for?
thanks in advance,
danielb
Posted by daniel bar on 2004-12-22
Posted by John Beimler on 2003-11-22