diff --git a/plugins/messageviewer/bodypartformatter/highlighter/highlighter.cpp b/plugins/messageviewer/bodypartformatter/highlighter/highlighter.cpp index 7ad20c87..aca0a6fd 100644 --- a/plugins/messageviewer/bodypartformatter/highlighter/highlighter.cpp +++ b/plugins/messageviewer/bodypartformatter/highlighter/highlighter.cpp @@ -1,87 +1,87 @@ /* Copyright (C) 2017-2019 Montel Laurent This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; see the file COPYING. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #include "highlighter.h" #include #include #include #include Highlighter::Highlighter(QTextStream *stream) : mStream(stream) { } Highlighter::~Highlighter() = default; void Highlighter::highlight(const QString &str) { *mStream << QStringLiteral("
");
 
     KSyntaxHighlighting::State state;
 
     int lineStart = 0;
     int lineEnd = str.indexOf(QLatin1Char('\n'));
 
     for (; lineEnd != -1; lineStart = lineEnd + 1, lineEnd = str.indexOf(QLatin1Char('\n'), lineStart)) {
         mCurrentLine = str.mid(lineStart, lineEnd - lineStart);
         state = highlightLine(mCurrentLine, state);
         *mStream << QLatin1Char('\n');
     }
     if (lineStart < str.size()) { // remaining content if str isn't ending with a newline
         mCurrentLine = str.mid(lineStart);
         state = highlightLine(mCurrentLine, state);
         *mStream << QLatin1Char('\n');
     }
     *mStream << QLatin1String("
\n"); } void Highlighter::applyFormat(int offset, int length, const KSyntaxHighlighting::Format &format) { if (!format.isDefaultTextStyle(theme())) { *mStream << QStringLiteral(""); } *mStream << mCurrentLine.mid(offset, length).toHtmlEscaped(); if (!format.isDefaultTextStyle(theme())) { *mStream << QStringLiteral(""); } }