Rewrite invalid tags instead of raising