fixed tags broken by <foreign> elements