Strip leading and trailing empty tags from HTML fragments