Improved HTML parser for Smart Search. Fixes #5340