There seems to be quite some duplication with the HTML parser here.