To start off I’d like to address the issue of why we need a formatter at all. Our ASP.NET/HTML designer leverages the MSHTML control as its design surface and as a result we have to deal with the fact that this control discards any/all formatting including whitespace preservation when working with HTML. If you’d actually like to see the effect of using MSHTML without a formatter (trust me you won’t be happy) simply rename htmlfmt80.bpl in your Delphi 8 bin directory, start the IDE and answer Yes to the “continue to load this package” error and start editing an HTML file. This package contains our HTML formatter and without it you simply get back the raw HTML from the MSHTML control.
One decision we made in Delphi 8 was to format only the content of the file starting after the first tag. There were several reasons we did this but the main reason was that we wanted to format as little of the file as possible and since many pages have sections that contain stylesheet and scripting information we thought this would be a good idea. As it turns out this wasn’t a very good idea and in some cases can result in HTML being either mangled or duplicated neither of which is good. It is possible in Delphi 8 to undo the changes made in the designer using Edit|Undo but that’s not always acceptible either.
In Diamondback we’ve completely fixed this problem and not only improved our formatter but also have relaxed the rules for creating non-HTML documents using the ASP.NET designer. For example, if you want to create an ASPX page that returns only XML (like an RSS feed) simply start a new ASP.NET page and delete all of the contents except the @ page directive at the top of the file then start adding your markup and the designer won’t mess it by trying to turn it into an HTML page. As a side note, we’ve continued to monitor the progress of the W3C’s HTML Tidy open source project and have worked to keep our libtidy.dll up-to-date.