From c38c6fe49e9c732f6e784cda04414d82bc092c48 Mon Sep 17 00:00:00 2001 From: Loren Burkholder Date: Sat, 20 Feb 2021 11:52:05 -0500 Subject: [PATCH] Format notifications according to the FreeDesktop specification --- src/notifications/ManagerLinux.cpp | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/notifications/ManagerLinux.cpp b/src/notifications/ManagerLinux.cpp index c6326254..adaa0a35 100644 --- a/src/notifications/ManagerLinux.cpp +++ b/src/notifications/ManagerLinux.cpp @@ -151,15 +151,26 @@ NotificationsManager::notificationClosed(uint id, uint reason) notificationIds.remove(id); } +/** + * @param text This should be an HTML-formatted string. + * + * If D-Bus says that notifications can have body markup, this function will + * automatically format the notification to follow the supported HTML subset + * specified at https://www.freedesktop.org/wiki/Specifications/StatusNotifierItem/Markup/ + */ QString NotificationsManager::formatNotification(const QString &text) { static auto capabilites = dbus.call("GetCapabilities").arguments(); for (auto x : capabilites) if (x.toStringList().contains("body-markup")) - return utils::markdownToHtml(text); + return QString(text) + .replace("", "") + .replace("", "") + .replace("", "") + .replace("", ""); - return QTextDocumentFragment::fromHtml(utils::markdownToHtml(text)).toPlainText(); + return QTextDocumentFragment::fromHtml(text).toPlainText(); } /**