Update code from HTML5 spec

@jarib I've still had to clean up downloaded spec manually so if you could take a look of what's going wrong with its parsing, that would be great.