diff options
author | LordMZTE <lord@mzte.de> | 2021-03-28 14:00:35 +0200 |
---|---|---|
committer | LordMZTE <lord@mzte.de> | 2021-03-28 14:00:35 +0200 |
commit | 4e6150f28e4b2fccc07e48b02ef957f4cee95297 (patch) | |
tree | ee918bbd3bc824d80070f6cce2e2c89a0fd2d39a /src/Utils.cpp | |
parent | remove incorrect include (diff) | |
download | nheko-4e6150f28e4b2fccc07e48b02ef957f4cee95297.tar.xz |
implement requested changes
Diffstat (limited to 'src/Utils.cpp')
-rw-r--r-- | src/Utils.cpp | 17 |
1 files changed, 7 insertions, 10 deletions
diff --git a/src/Utils.cpp b/src/Utils.cpp index 4be3c480..05e1a584 100644 --- a/src/Utils.cpp +++ b/src/Utils.cpp @@ -18,7 +18,7 @@ #include <QXmlStreamReader> #include <cmath> -#include <qtextboundaryfinder.h> +#include <QTextBoundaryFinder> #include <variant> #include <cmark.h> @@ -26,7 +26,6 @@ #include "Cache.h" #include "Config.h" #include "EventAccessors.h" -#include "Logging.h" #include "MatrixClient.h" #include "UserSettingsPage.h" @@ -509,24 +508,22 @@ utils::markdownToHtml(const QString &text, bool rainbowify) continue; // get text in current node - const char *tmp_buf = cmark_node_get_literal(cur); - std::string nodeText(tmp_buf); - auto qNodeText = QString::fromStdString(nodeText); + QString nodeText(cmark_node_get_literal(cur)); // create buffer to append rainbow text to std::string buf; int boundaryStart = 0; int boundaryEnd = 0; // use QTextBoundaryFinder to iterate ofer graphemes QTextBoundaryFinder tbf(QTextBoundaryFinder::BoundaryType::Grapheme, - qNodeText); + nodeText); while ((boundaryEnd = tbf.toNextBoundary()) != -1) { // Split text to get current char auto curChar = - qNodeText.mid(boundaryStart, boundaryEnd - boundaryStart); + nodeText.midRef(boundaryStart, boundaryEnd - boundaryStart); boundaryStart = boundaryEnd; - // Don't rainbowify spaces - if (curChar == " ") { - buf.push_back(' '); + // Don't rainbowify whitespaces + if (curChar.trimmed().isEmpty()) { + buf.append(curChar.toString().toStdString()); continue; } |