Rewrite the AST to conform to the W3C grammar