diff options
| author | Danilo M. <danix@danix.xyz> | 2026-09-29 16:16:36 +0200 |
|---|---|---|
| committer | Danilo M. <danix@danix.xyz> | 2026-09-29 16:16:36 +0200 |
| commit | 8215c7bcde3e1fcb3635059c408b4b97e42f2141 (patch) | |
| tree | e994d2690e0d6ee06b28eb0976ec570d380341b1 | |
| parent | 0da34c765da9b9c831befdab659c9eb0c79c9079 (diff) | |
| download | quickshell-8215c7bcde3e1fcb3635059c408b4b97e42f2141.tar.gz quickshell-8215c7bcde3e1fcb3635059c408b4b97e42f2141.zip | |
feat(notifications): render bodies as Markdown
Balloon and drawer bodies switch from RichText to Qt's MarkdownText
(CommonMark plus GitHub extensions). Raw HTML still goes through Qt's
HTML importer, so body-markup senders keep working.
Markdown images fetch their destination the same way an <img> does,
which the existing sanitize filter would miss since it only inspects
tags. sanitize now escapes every "` and `![alt][ref]` fetch just as an <img> does, and parsing + // their destinations would mean reimplementing CommonMark's link grammar. + // Escaping the bracket turns every one into literal text instead, local or + // not. Raw HTML inside Markdown goes through Qt's HTML importer, so the + // tag filter below still applies to it. function sanitize(body) { function decode(s) { return s.replace(/&(?:#x([0-9a-f]+)|#(\d+)|(amp|colon|sol|tab|quot));/gi, @@ -84,7 +91,7 @@ Singleton { return { amp: "&", colon: ":", sol: "/", tab: "\t", quot: "\"" }[name.toLowerCase()]; }); } - return (body || "").replace(/<img\b[^>]*>/gi, function (tag) { + return (body || "").replace(/!\[/g, "!\\[").replace(/<img\b[^>]*>/gi, function (tag) { const re = /(?:^|\s)src\s*=\s*(?:"([^"]*)"|'([^']*)'|([^\s>]+))/gi; let m, found = false, local = true; while ((m = re.exec(tag))) { |
