- Affected version
- 2.2.6
Previous
As a result of this change; https://xenforo.com/community/threads/inefficient-code-in-page_container.193322/ this no longer works.
This sort of regex looks able to extract and convert things as required without requiring a full LESS parser.
parse_less_color
would render the to #xxyyzz format which Discord would read and use to tint the embed.As a result of this change; https://xenforo.com/community/threads/inefficient-code-in-page_container.193322/ this no longer works.
This sort of regex looks able to extract and convert things as required without requiring a full LESS parser.
PHP:
if (\preg_match('/^\s*(?:rgb|rgba)\s*\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*(?:,\s*(\d{1,3})\s*)?\)\s*$/i', $value, $matches))
{
$r = $matches[2];
$g = $matches[3];
$b = $matches[4];
$a = $matches[5] ?? '';
if ($a === '')
{
return \sprintf("#%02x%02x%02x", $r, $g, $b);
}
else
{
return \sprintf("#%02x%02x%02x%02x", $r, $g, $b, $a);
}
}