I'm creating an ASP.NET server control using the HtmlTextWriter class. My understanding is that it's a nice class to use for making sure my output HTML is valid. I assumed it would format things nicely as well, but it does a bunch of strange stuff that makes the output hard to read.
Are there some settings or something I can play with to get this looking like someone took the time to properly format it, or is it just a downside of using this class? Here are some examples of the ugly formatting I'm talking about:
- Inconsistent use of self-closing tags. With some tags I get them, and others I don't.
- Random newlines between tags.
- Lack of newlines in appropriate places.
- Mismatched indentation.
This is actually what I'm trying to reproduce:
<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" id="MySWF" width="100" height="100" codebase="https://fpdownload.macromedia.com/get/flashplayer/current/swflash.cab">
<param name="movie" value="/MySWF.swf"></param>
<param name="quality" value="high" />
<param name="allowScriptAccess" value="sameDomain" />
<embed align="middle" pluginspage="https://www.adobe.com/go/getflashplayer" width="100" quality="high" height="100" loop="false" name="MySWF" type="application/x-shockwave-flash" play="true" allowscriptaccess="sameDomain" src="/MySWF.swf" />
</object>
...and this is what I'm getting:
<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" id="MySWF" width="100" height="100" codebase="https://fpdownload.macromedia.com/get/flashplayer/current/swflash.cab">
<param name="movie" value="/MySWF.swf">
</param><param name="quality" value="high">
</param><param name="allowScriptAccess" value="sameDomain">
</param><embed align="middle" pluginspage="https://www.adobe.com/go/getflashplayer" width="100" quality="high" height="100" loop="false" name="MySWF" type="application/x-shockwave-flash" play="true" allowscriptaccess="sameDomain" src="/MySWF.swf" />
</object>