diff --git a/src/entities/note.cpp b/src/entities/note.cpp
index c1c18095cf..447043b296 100644
--- a/src/entities/note.cpp
+++ b/src/entities/note.cpp
@@ -2034,11 +2034,12 @@ QString Note::textToMarkdownHtml(QString str, const QString& notesPath,
int endline = str.indexOf(QChar('\n'), currentCbPos);
QString lang = str.mid(currentCbPos +3, endline - (currentCbPos + 3));
//in case someone decides to put ``` code ``` on the same line
+ //we skip it because it is inline code and not codeBlock
if (lang.contains(QLatin1String("```"))) {
- //reset the endline to ``, the third backtick will be taken care of below
- endline = currentCbPos + 2;
- //empty the lang
- lang = QLatin1String("");
+ int nextEnd = str.indexOf(QLatin1String("```"), currentCbPos + 3);
+ nextEnd += 3;
+ currentCbPos = str.indexOf(QLatin1String("```"), nextEnd);
+ continue;
}
//move start pos to after the endline
diff --git a/src/helpers/codetohtmlconverter.cpp b/src/helpers/codetohtmlconverter.cpp
index 2f813beecd..7286fbdece 100644
--- a/src/helpers/codetohtmlconverter.cpp
+++ b/src/helpers/codetohtmlconverter.cpp
@@ -416,8 +416,8 @@ int CodeToHtmlConverter::highlightComment(QString &output, int i, bool isSingleL
} else {
endPos = _input.indexOf(QLatin1String("*/"), i);
if (endPos == -1) {
- //-1, otherwise we ruin the codeblock end and backticks will be visible in rendered html
- endPos = _input.length() - 1;
+ //look for the last endline
+ endPos = _input.lastIndexOf(QLatin1Char('\n'));
} else {
endPos += 2;
}
diff --git a/tests/unit_tests/testcases/app/test_notes.cpp b/tests/unit_tests/testcases/app/test_notes.cpp
index 26d5907577..cbbc863c03 100644
--- a/tests/unit_tests/testcases/app/test_notes.cpp
+++ b/tests/unit_tests/testcases/app/test_notes.cpp
@@ -174,11 +174,24 @@ void TestNotes::testCodeToHtmlConversionSingleLineComment()
void TestNotes::testCodeToHtmlConversionMultiLineComment()
{
QString comment = QStringLiteral("/*hello my qownnotes blah blah single line*/\n");
+ QString commentTrueMultiLine = QStringLiteral("/*hello my \nqownnotes blah \nblah single line*/\n");
+ QString commentTrueMultiLineNoEnd = QStringLiteral("/*hello my \nqownnotes blah \nblah single line\n");
+
CodeToHtmlConverter c1(comment.midRef(0, comment.length()), QStringLiteral("cpp"));
+ CodeToHtmlConverter c2(commentTrueMultiLine.midRef(0, commentTrueMultiLine.length()), QStringLiteral("cpp"));
+ CodeToHtmlConverter c3(commentTrueMultiLineNoEnd.midRef(0, commentTrueMultiLineNoEnd.length()), QStringLiteral("cpp"));
+
QString outputMultiLineComment = c1.process();
- QString expectedOutputMultiLineComment = QStringLiteral("\n");
+ QString outputTrueMultiLine = c2.process();
+ QString outputTrueMultiLineNoEnd = c3.process();
+
+ QString expectedMultiLineComment = QStringLiteral("\n");
+ QString expectedTrueMultiLine = QStringLiteral("\n");
+ QString expectedTrueMultiLineNoEnd = QStringLiteral("\n");
- QVERIFY(outputMultiLineComment == expectedOutputMultiLineComment);
+ QVERIFY(outputMultiLineComment == expectedMultiLineComment);
+ QVERIFY(outputTrueMultiLine == expectedTrueMultiLine);
+ QVERIFY(outputTrueMultiLineNoEnd == expectedTrueMultiLineNoEnd);
}
void TestNotes::testCodeToHtmlNumericLiterals()