For the purposes of this discussion, let "normal text" mean text that is not enclosed in HTML tags and is not a whitespace character, an dlet "indentation mark" mean two spaces.
* Any whitespace immediately following any HTML tag should be removed.
* Any whitespace characters or newlines between an HTML tag and normal text should be removed.
Wrong:
<td class="ralign">
Monday, May 30</td>
Correct:
<td class="ralign">Monday, May 30</td>
* All opening <table>, <th>, <tbody>, and <thead> tags should be followed by a newline and one more indentation_mark than what the previous line was.
Wrong:
<tbody><tr><td style
Correct:
<tbody>
<tr>
<td style
* All closing <table>, <th>, <tbody>, and <thead> tags should be immediately followed by a newline and one less number of indentations than the number of indentations on the previous line.
Wrong:
</td></tr> </tbody> </table>
Correct:
</td>
</tr>
</tbody>
</table>
* Remove all newlines between opening and closing <a> and <span> tags.
Wrong:
<a href="http://www.google.com">
Do you Google?</a>
Correct:
<a href="http://www.google.com">Do you Google?</a>
Is any of this possible in Vim? If not, can someone recommend another utility to accomplish this?
I assume you're talking about: http://www.w3.org/People/Raggett/tidy/
I'd also recommend using that rather than Vim to reformat HTML.
Something you might consider, is using tidy in either the 'equalprg' or 'formatprg' option of Vim. That way you can invoke tidy automatically using Vim as you edit.