Moved html patch to StringUtils
Signed-off-by: SabrePenguin <lknofczynski@gmail.com>
This commit is contained in:
parent
5348a90a15
commit
cec27fd014
3 changed files with 23 additions and 17 deletions
|
@ -212,3 +212,23 @@ QPair<QString, QString> StringUtils::splitFirst(const QString& s, const QRegular
|
|||
right = s.mid(end);
|
||||
return qMakePair(left, right);
|
||||
}
|
||||
|
||||
QString StringUtils::htmlListPatch(QString htmlStr)
|
||||
{
|
||||
int pos = htmlStr.indexOf("</ul>");
|
||||
int imgPos;
|
||||
while (pos != -1) {
|
||||
pos = pos + 5; // 5 is the size of the </ul> tag
|
||||
imgPos = htmlStr.indexOf("<img", pos);
|
||||
if (imgPos == -1)
|
||||
break; // no image after the tag
|
||||
|
||||
auto textBetween = htmlStr.mid(pos, imgPos - pos).trimmed(); // trim all white spaces
|
||||
|
||||
if (textBetween.isEmpty())
|
||||
htmlStr.insert(pos, "<br>");
|
||||
|
||||
pos = htmlStr.indexOf("</ul>", pos);
|
||||
}
|
||||
return htmlStr;
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue