Made Regex static and const, removed dist
Signed-off-by: SabrePenguin <lknofczynski@gmail.com>
This commit is contained in:
parent
f43873a8ba
commit
fa2c2a7c85
@ -213,14 +213,14 @@ QPair<QString, QString> StringUtils::splitFirst(const QString& s, const QRegular
|
|||||||
return qMakePair(left, right);
|
return qMakePair(left, right);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static const QRegularExpression ulMatcher("<\\s*/\\s*ul\\s*>");
|
||||||
|
|
||||||
QString StringUtils::htmlListPatch(QString htmlStr)
|
QString StringUtils::htmlListPatch(QString htmlStr)
|
||||||
{
|
{
|
||||||
QRegularExpression match("<\\s/\\s*ul\\s*>");
|
int pos = htmlStr.indexOf(ulMatcher);
|
||||||
int pos = htmlStr.indexOf(match);
|
int imgPos;
|
||||||
int imgPos, dist;
|
|
||||||
while (pos != -1) {
|
while (pos != -1) {
|
||||||
dist = htmlStr.indexOf(">", pos) - pos + 1; // Get the size of the </ul> tag. Add one for zeroeth index
|
pos = htmlStr.indexOf(">", pos) + 1; // Get the size of the </ul> tag. Add one for zeroeth index
|
||||||
pos = pos + dist;
|
|
||||||
imgPos = htmlStr.indexOf("<img ", pos);
|
imgPos = htmlStr.indexOf("<img ", pos);
|
||||||
if (imgPos == -1)
|
if (imgPos == -1)
|
||||||
break; // no image after the tag
|
break; // no image after the tag
|
||||||
@ -230,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(match, pos);
|
pos = htmlStr.indexOf(ulMatcher, pos);
|
||||||
}
|
}
|
||||||
return htmlStr;
|
return htmlStr;
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user