Fix inline custom emojis in codeblocks

Make sure that custom emojis in inline code blocks are not turned into images.

By calling preprocess text in `texthandler` the whole function can be simplified as it will now never be called on any text inside any code block (which was the reason for all the split stuff previously).

BUG: 477512
This commit is contained in:
James Graham
2023-12-09 14:28:00 +00:00
parent c396024a26
commit d25340bc31
5 changed files with 64 additions and 19 deletions

View File

@@ -16,6 +16,7 @@
#include <Kirigami/Platform/PlatformTheme>
#include "models/customemojimodel.h"
#include "utils.h"
static const QStringList allowedTags = {
@@ -63,13 +64,21 @@ QString TextHandler::handleSendText()
next();
QString nextTokenBuffer = m_nextToken;
if (m_nextTokenType == Type::Text || m_nextTokenType == Type::TextCode) {
switch (m_nextTokenType) {
case Text:
nextTokenBuffer = escapeHtml(nextTokenBuffer);
} else if (m_nextTokenType == Type::Tag) {
nextTokenBuffer = CustomEmojiModel::instance().preprocessText(nextTokenBuffer);
break;
case TextCode:
nextTokenBuffer = escapeHtml(nextTokenBuffer);
break;
case Tag:
if (!isAllowedTag(getTagType())) {
nextTokenBuffer = QString();
}
nextTokenBuffer = cleanAttributes(getTagType(), nextTokenBuffer);
default:
break;
}
outputString.append(nextTokenBuffer);