Update launcher/Markdown.cpp
Co-authored-by: Alexandru Ionut Tripon <alexandru.tripon97@gmail.com> Signed-off-by: SabrePenguin <147069705+SabrePenguin@users.noreply.github.com>
This commit is contained in:
parent
2cfe482298
commit
6ecd2c7f31
@ -27,17 +27,22 @@ QString markdownToHTML(const QString& markdown)
|
|||||||
|
|
||||||
free(buffer);
|
free(buffer);
|
||||||
|
|
||||||
// Insert a breakpoint between a </ul> and <img> tag as this can cause visual bugs
|
int pos = htmlStr.indexOf("</ul>");
|
||||||
int first_pos = htmlStr.indexOf("</ul>");
|
int imgPos;
|
||||||
int img_pos;
|
while (pos != -1) {
|
||||||
while (first_pos != -1) {
|
pos = pos + 5; // 5 is the size of the </ul> tag
|
||||||
img_pos = htmlStr.indexOf("<img", first_pos);
|
imgPos = htmlStr.indexOf("<img", pos);
|
||||||
|
if (imgPos == -1)
|
||||||
|
break; // no image after the tag
|
||||||
|
|
||||||
if (img_pos - (first_pos + 5) < 3 && img_pos - (first_pos + 5) > -1) // 5 is the size of the </ul> tag
|
auto textBetween = htmlStr.mid(pos, imgPos - pos).trimmed(); // trim all white spaces
|
||||||
htmlStr.insert(img_pos, "<br>");
|
|
||||||
|
|
||||||
first_pos = htmlStr.indexOf("</ul>", first_pos + 5);
|
if (textBetween.isEmpty())
|
||||||
|
htmlStr.insert(pos, "<br>");
|
||||||
|
|
||||||
|
pos = htmlStr.indexOf("</ul>", pos);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
return htmlStr;
|
return htmlStr;
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user