Remove refs before escaped tags