The formatting goes away when writing nice indented html including comments and stuff and then you edit the text area with the WYSIWYG editor to copy Spotfire controls (which is tricky btw) and then you go back to the html to see it all "optimized". So the work around is to copy the code, pasted in some html formatter too with the risk of unintentionally share confidential information and paste it back.