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:
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.
Download pyTidy, a simple Python wrapper of TidyLib that has just the minimal interface described above.
- Install SWIG
- Install Tidy
- Edit the variables at the top of the Makefile to
reflect your current environment.
- Set to the 'Examples' directory of your SWIG installation.
- Change to point to the include directory for your TidyLib install.
- Change to the full path of libtidy.a (libtidy.lib on Windows).
Type 'make' to build. This will build two files:
_pytidy.dllon Windows) and
Copy both of these files into your project, or the right location in your Python libraries.
Version 0.1 - Initial Release. Currently untested on Windows.
Yes, I would like to automate this whole process using distutils, but that will have to wait for a later release.