Add inline colour support for rgb(12,34,56) / rgba(1,2,3,0.4) colours
Also improve the regexes
This commit is contained in:
parent
82fc20ed0d
commit
0c20484b5a
1 changed files with 6 additions and 4 deletions
|
@ -50,10 +50,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 <div class="colourbox" style="background-color:#$2"></div> $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 <div class="colourbox" style="background-color:$2"></div>';
|
||||
text = text.replace(hexColourRegex, substitute);
|
||||
text = text.replace(rgbColourRegex, substitute);
|
||||
return text;
|
||||
};
|
||||
});
|
||||
|
||||
|
|
Loading…
Reference in a new issue