Added a naive implementation of a <br> inserter

Signed-off-by: SabrePenguin <lknofczynski@gmail.com>
This commit is contained in:
SabrePenguin 2024-04-25 14:56:22 -04:00
parent e777201187
commit dedea2c05d

View File

@ -24,7 +24,15 @@ QString markdownToHTML(const QString& markdown)
char* buffer = cmark_markdown_to_html(markdownData.constData(), markdownData.length(), CMARK_OPT_NOBREAKS | CMARK_OPT_UNSAFE);
QString htmlStr(buffer);
int first_pos = htmlStr.indexOf("</ul>");
int img_pos = 0;
while( first_pos != -1 )
{
img_pos = htmlStr.indexOf("<img", first_pos);
if ( img_pos - (first_pos + 5) < 3 && img_pos - (first_pos + 5) != -1)
htmlStr.insert(img_pos, "<br>");
first_pos = htmlStr.indexOf("</ul>", first_pos+5);
}
free(buffer);
return htmlStr;