Switched </ul> to a Regex expression

Signed-off-by: SabrePenguin <lknofczynski@gmail.com>
This commit is contained in:
SabrePenguin 2024-04-30 23:28:50 -04:00 committed by Trial97
parent 401de52f61
commit 875c6bbada
No known key found for this signature in database
GPG Key ID: 55EF5DA53DB36318

View File

@ -215,11 +215,13 @@ QPair<QString, QString> StringUtils::splitFirst(const QString& s, const QRegular
QString StringUtils::htmlListPatch(QString htmlStr) QString StringUtils::htmlListPatch(QString htmlStr)
{ {
int pos = htmlStr.indexOf("</ul>"); QRegularExpression match("<w*/w*ulw*>|<w*ulw*/w*>");
int imgPos; int pos = htmlStr.indexOf(match);
int imgPos, dist;
while (pos != -1) { while (pos != -1) {
pos = pos + 5; // 5 is the size of the </ul> tag dist = htmlStr.indexOf(">", pos) - pos + 1; // Get the size of the </ul> tag. Add one for zeroeth index
imgPos = htmlStr.indexOf("<img", pos); pos = pos + dist;
imgPos = htmlStr.indexOf("<img ", pos);
if (imgPos == -1) if (imgPos == -1)
break; // no image after the tag break; // no image after the tag
@ -228,7 +230,7 @@ QString StringUtils::htmlListPatch(QString htmlStr)
if (textBetween.isEmpty()) if (textBetween.isEmpty())
htmlStr.insert(pos, "<br>"); htmlStr.insert(pos, "<br>");
pos = htmlStr.indexOf("</ul>", pos); pos = htmlStr.indexOf(match, pos);
} }
return htmlStr; return htmlStr;
} }