diff --git a/launcher/Markdown.cpp b/launcher/Markdown.cpp
index 31e026dc7..f9081057c 100644
--- a/launcher/Markdown.cpp
+++ b/launcher/Markdown.cpp
@@ -26,18 +26,23 @@ QString markdownToHTML(const QString& markdown)
QString htmlStr(buffer);
free(buffer);
-
- // Insert a breakpoint between a and
tag as this can cause visual bugs
- int first_pos = htmlStr.indexOf("");
- int img_pos;
- while (first_pos != -1) {
- img_pos = htmlStr.indexOf("
-1) // 5 is the size of the tag
- htmlStr.insert(img_pos, "
");
+ int pos = htmlStr.indexOf("");
+ int imgPos;
+ while (pos != -1) {
+ pos = pos + 5; // 5 is the size of the tag
+ imgPos = htmlStr.indexOf("
", first_pos + 5);
+ auto textBetween = htmlStr.mid(pos, imgPos - pos).trimmed(); // trim all white spaces
+
+ if (textBetween.isEmpty())
+ htmlStr.insert(pos, "
");
+
+ pos = htmlStr.indexOf("", pos);
}
+
return htmlStr;
}
\ No newline at end of file