fix htmltoxhtml

This commit is contained in:
Kulikova Svetlana
2021-01-25 17:44:18 +03:00
parent bbf97e2098
commit 91bc1f74ae

View File

@ -27,11 +27,10 @@ static std::string mhtTohtml(std::string& sFileContent);
static void replace_all(std::string& s, const std::string& s1, const std::string& s2)
{
size_t pos = s.find(s1);
size_t l = s2.length();
while(pos != std::string::npos)
{
s.replace(pos, s1.length(), s2);
pos = s.find(s1, pos + l);
pos = s.find(s1, pos + s2.length());
}
}
@ -63,6 +62,17 @@ static std::wstring htmlToXhtml(std::string& sFileContent)
}
}
// Избавление от <a/>
size_t posA = sFileContent.find("<a ");
while(posA != std::string::npos)
{
size_t nBegin = sFileContent.find('<', posA + 1);
size_t nEnd = sFileContent.find("/>", posA);
if(nEnd < nBegin)
sFileContent.replace(nEnd, 2, "></a>");
posA = sFileContent.find("<a ", nBegin);
}
// Gumbo
GumboOptions options = kGumboDefaultOptions;
GumboOutput* output = gumbo_parse_with_options(&options, sFileContent.data(), sFileContent.length());