diff --git a/js/filters.js b/js/filters.js index 4f0d6d9..7b4abfd 100644 --- a/js/filters.js +++ b/js/filters.js @@ -57,10 +57,12 @@ weechat.filter('inlinecolour', function() { } // only match 6-digit colour codes, 3-digit ones have too many false positives (issue numbers, etc) - var hexColourRegex = /(^|[^&])\#([0-9a-f]{6})($|[^\w'"])/gmi; - var substitute = '$1#$2
$3'; - - return text.replace(hexColourRegex, substitute); + var hexColourRegex = /(^|[^&])(\#[0-9a-f]{6};?)(?!\w)/gmi; + var rgbColourRegex = /(.?)(rgba?\((?:\s*\d+\s*,){2}\s*\d+\s*(?:,\s*[\d.]+\s*)?\);?)/gmi; + var substitute = '$1$2
'; + text = text.replace(hexColourRegex, substitute); + text = text.replace(rgbColourRegex, substitute); + return text; }; });