Add somewhat better blockquote styling

Quotes are now "quoted" and also have a different background.
This commit is contained in:
Joshua Goins
2023-11-03 17:34:52 -04:00
parent e3cf85aa8c
commit dc6b539ddf
3 changed files with 18 additions and 0 deletions

View File

@@ -67,6 +67,18 @@ table td {
border: 1px solid black;
padding: 3px;
}
blockquote {
margin: 0;
}
blockquote table {
width: 100%;
border-width: 0;
background-color:" + Kirigami.Theme.alternateBackgroundColor + ";
}
blockquote td {
width: 100%;
padding: " + Kirigami.Units.largeSpacing + ";
}
pre {
white-space: pre-wrap
}

View File

@@ -134,6 +134,10 @@ QString TextHandler::handleRecieveRichText(Qt::TextFormat inputFormat, const Neo
nextTokenType();
}
// Apply user style to blockquotes
// Unfortunately some attributes can be only be used on table cells, so we need to wrap the content in one.
outputString.replace(TextRegex::blockQuote, QStringLiteral(R"(<blockquote><table><tr><td>“\1”</td></tr></table></blockquote>)"));
// If the message is an emote add the user pill to the front of the message.
if (event != nullptr) {
auto e = eventCast<const Quotient::RoomMessageEvent>(event);

View File

@@ -19,6 +19,8 @@ static const QRegularExpression removeReply{QStringLiteral("> <.*?>.*?\\n\\n"),
static const QRegularExpression removeRichReply{QStringLiteral("<mx-reply>.*?</mx-reply>"), QRegularExpression::DotMatchesEverythingOption};
static const QRegularExpression codePill{QStringLiteral("<pre><code[^>]*>(.*?)</code></pre>"), QRegularExpression::DotMatchesEverythingOption};
static const QRegularExpression userPill{QStringLiteral("(<a href=\"https://matrix.to/#/@.*?:.*?\">.*?</a>)"), QRegularExpression::DotMatchesEverythingOption};
static const QRegularExpression blockQuote{QStringLiteral("<blockquote>\n?(?:<p>)?(.*?)(?:</p>)?\n?</blockquote>"),
QRegularExpression::DotMatchesEverythingOption};
static const QRegularExpression strikethrough{QStringLiteral("<del>(.*?)</del>"), QRegularExpression::DotMatchesEverythingOption};
static const QRegularExpression mxcImage{QStringLiteral(R"AAA(<img(.*?)src="mxc:\/\/(.*?)\/(.*?)"(.*?)>)AAA")};
static const QRegularExpression plainUrl(