The Tidy library has been around for years now and there are ports to multiple platforms. For Windows it is available as a COM assembly. Unfortunately that is not ideal for working with .NET, but there is a good wrapper for it that still requires the COM assembly to be registered before it can be used. Registration is not difficult, as explained on the project website, but doing it manually every time can be a hassle. To avoid the hassle I created installer along with a simple helper class.
With Tidy for .NET you simply run the installer on any machine that will be using the Tidy library. The installer will copy the COM assembly, named TidyATL.dll, to the installation folder and register it for you. In addition to placing Tidy functionality on the machine, it also adds an MSBuild Task to make it easy to automate if you have a need for that. Along with the project I have created a sample website that uses the TinyMCE editor as a demo for using the
MarkupCleaner class that I created to wrap the Tidy library. When the PostBack event occurs it passes the value from the
TextBox to the cleaner and displays the result inside of a
PlaceHolder. It also shows the unmodified version in another
PlaceHolder for comparison. You can use this sample website to try out how well it works with your editor of choice as well as different Tidy settings. The following code is all you will need.
You can get everything with the following links: