mirror of
https://github.com/Nheko-Reborn/nheko.git
synced 2024-11-25 20:48:52 +03:00
Fix emojis being split by rainbows
This commit is contained in:
parent
326f48d87f
commit
edaeb3ccde
1 changed files with 5 additions and 5 deletions
|
@ -517,18 +517,20 @@ utils::markdownToHtml(const QString &text, bool rainbowify)
|
||||||
QTextBoundaryFinder tbf(QTextBoundaryFinder::BoundaryType::Grapheme,
|
QTextBoundaryFinder tbf(QTextBoundaryFinder::BoundaryType::Grapheme,
|
||||||
nodeText);
|
nodeText);
|
||||||
while ((boundaryEnd = tbf.toNextBoundary()) != -1) {
|
while ((boundaryEnd = tbf.toNextBoundary()) != -1) {
|
||||||
|
charIdx++;
|
||||||
// Split text to get current char
|
// Split text to get current char
|
||||||
auto curChar =
|
auto curChar =
|
||||||
nodeText.midRef(boundaryStart, boundaryEnd - boundaryStart);
|
nodeText.midRef(boundaryStart, boundaryEnd - boundaryStart);
|
||||||
boundaryStart = boundaryEnd;
|
boundaryStart = boundaryEnd;
|
||||||
// Don't rainbowify whitespaces
|
// Don't rainbowify whitespaces
|
||||||
if (curChar.trimmed().isEmpty()) {
|
if (curChar.trimmed().isEmpty() ||
|
||||||
buf.append(curChar.toString());
|
codepointIsEmoji(curChar.toUcs4().first())) {
|
||||||
|
buf.append(curChar);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
// get correct color for char index
|
// get correct color for char index
|
||||||
auto color = QColor::fromHsvF(1.0 / textLen * charIdx, 1.0, 1.0);
|
auto color = QColor::fromHsvF((charIdx - 1.0) / textLen, 1.0, 1.0);
|
||||||
// format color for HTML
|
// format color for HTML
|
||||||
auto colorString = color.name(QColor::NameFormat::HexRgb);
|
auto colorString = color.name(QColor::NameFormat::HexRgb);
|
||||||
// create HTML element for current char
|
// create HTML element for current char
|
||||||
|
@ -537,8 +539,6 @@ utils::markdownToHtml(const QString &text, bool rainbowify)
|
||||||
.arg(curChar);
|
.arg(curChar);
|
||||||
// append colored HTML element to buffer
|
// append colored HTML element to buffer
|
||||||
buf.append(curCharColored);
|
buf.append(curCharColored);
|
||||||
|
|
||||||
charIdx++;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// create HTML_INLINE node to prevent HTML from being escaped
|
// create HTML_INLINE node to prevent HTML from being escaped
|
||||||
|
|
Loading…
Reference in a new issue