mirror of
https://github.com/Nheko-Reborn/nheko.git
synced 2024-11-22 11:00:48 +03:00
implement requested changes
This commit is contained in:
parent
64e29b07e2
commit
4e6150f28e
2 changed files with 8 additions and 11 deletions
|
@ -18,7 +18,7 @@
|
||||||
#include <QXmlStreamReader>
|
#include <QXmlStreamReader>
|
||||||
|
|
||||||
#include <cmath>
|
#include <cmath>
|
||||||
#include <qtextboundaryfinder.h>
|
#include <QTextBoundaryFinder>
|
||||||
#include <variant>
|
#include <variant>
|
||||||
|
|
||||||
#include <cmark.h>
|
#include <cmark.h>
|
||||||
|
@ -26,7 +26,6 @@
|
||||||
#include "Cache.h"
|
#include "Cache.h"
|
||||||
#include "Config.h"
|
#include "Config.h"
|
||||||
#include "EventAccessors.h"
|
#include "EventAccessors.h"
|
||||||
#include "Logging.h"
|
|
||||||
#include "MatrixClient.h"
|
#include "MatrixClient.h"
|
||||||
#include "UserSettingsPage.h"
|
#include "UserSettingsPage.h"
|
||||||
|
|
||||||
|
@ -509,24 +508,22 @@ utils::markdownToHtml(const QString &text, bool rainbowify)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
// get text in current node
|
// get text in current node
|
||||||
const char *tmp_buf = cmark_node_get_literal(cur);
|
QString nodeText(cmark_node_get_literal(cur));
|
||||||
std::string nodeText(tmp_buf);
|
|
||||||
auto qNodeText = QString::fromStdString(nodeText);
|
|
||||||
// create buffer to append rainbow text to
|
// create buffer to append rainbow text to
|
||||||
std::string buf;
|
std::string buf;
|
||||||
int boundaryStart = 0;
|
int boundaryStart = 0;
|
||||||
int boundaryEnd = 0;
|
int boundaryEnd = 0;
|
||||||
// use QTextBoundaryFinder to iterate ofer graphemes
|
// use QTextBoundaryFinder to iterate ofer graphemes
|
||||||
QTextBoundaryFinder tbf(QTextBoundaryFinder::BoundaryType::Grapheme,
|
QTextBoundaryFinder tbf(QTextBoundaryFinder::BoundaryType::Grapheme,
|
||||||
qNodeText);
|
nodeText);
|
||||||
while ((boundaryEnd = tbf.toNextBoundary()) != -1) {
|
while ((boundaryEnd = tbf.toNextBoundary()) != -1) {
|
||||||
// Split text to get current char
|
// Split text to get current char
|
||||||
auto curChar =
|
auto curChar =
|
||||||
qNodeText.mid(boundaryStart, boundaryEnd - boundaryStart);
|
nodeText.midRef(boundaryStart, boundaryEnd - boundaryStart);
|
||||||
boundaryStart = boundaryEnd;
|
boundaryStart = boundaryEnd;
|
||||||
// Don't rainbowify spaces
|
// Don't rainbowify whitespaces
|
||||||
if (curChar == " ") {
|
if (curChar.trimmed().isEmpty()) {
|
||||||
buf.push_back(' ');
|
buf.append(curChar.toString().toStdString());
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -525,7 +525,7 @@ InputBar::command(QString command, QString args)
|
||||||
} else if (command == "plain") {
|
} else if (command == "plain") {
|
||||||
message(args, MarkdownOverride::OFF);
|
message(args, MarkdownOverride::OFF);
|
||||||
} else if (command == "rainbow") {
|
} else if (command == "rainbow") {
|
||||||
message(args, MarkdownOverride::NOT_SPECIFIED, true);
|
message(args, MarkdownOverride::ON, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue