diff --git a/autotests/texthandlertest.cpp b/autotests/texthandlertest.cpp index 1ea1487e8..47fb473a3 100644 --- a/autotests/texthandlertest.cpp +++ b/autotests/texthandlertest.cpp @@ -530,6 +530,9 @@ void TextHandlerTest::componentOutput_data() QTest::newRow("quote") << u"

Text

\n
\n

blockquote

\n
"_s << QList{MessageComponent{MessageComponentType::Text, u"Text"_s, {}}, MessageComponent{MessageComponentType::Quote, u"“blockquote”"_s, {}}}; + QTest::newRow("multiple paragraph quote") << u"
\n

blockquote

\n

next paragraph

\n
"_s + << QList{ + MessageComponent{MessageComponentType::Quote, u"

“blockquote

\n

next paragraph”

"_s, {}}}; QTest::newRow("no tag first paragraph") << u"Text\n

Text

"_s << QList{MessageComponent{MessageComponentType::Text, u"Text"_s, {}}, MessageComponent{MessageComponentType::Text, u"Text"_s, {}}}; diff --git a/src/texthandler.cpp b/src/texthandler.cpp index cc4075ee0..6318ed437 100644 --- a/src/texthandler.cpp +++ b/src/texthandler.cpp @@ -381,18 +381,20 @@ QString TextHandler::stripBlockTags(QString string, const QString &tagType) cons } } if (tagType == u"blockquote"_s) { + int startQuotationIndex = 0; + int endQuotationIndex = string.size(); + + // We have to insert the quotation marks inside of the existing + // paragraphs, otherwise we add unnecessary line breaks. if (string.startsWith(u"

"_s)) { - string.remove(0, string.indexOf(u'>') + 1); - string.remove(string.indexOf(u"

"_s), string.size()); + startQuotationIndex = string.indexOf(u">") + 1; + endQuotationIndex = string.lastIndexOf(u"

") + 1; } + // This is not a normal quotation mark but U+201C - if (!string.startsWith(u'“')) { - string.prepend(u'“'); - } + string.insert(startQuotationIndex, u'“'); // This is U+201D - if (!string.endsWith(u'”')) { - string.append(u'”'); - } + string.insert(endQuotationIndex, u'”'); } return string;