Add support for rgb() colors (XF 2)
authorTim Düsterhus <tim@bastelstu.be>
Thu, 6 Feb 2020 12:12:53 +0000 (13:12 +0100)
committerTim Düsterhus <tim@bastelstu.be>
Thu, 5 Mar 2020 16:40:33 +0000 (17:40 +0100)
files/lib/system/exporter/XF2xExporter.class.php

index 327a59010dd679b8d8e5b9fd7eb05325f2833934..3164cc03122e26cc6a7713aec965f01fd9f13150 100644 (file)
@@ -1723,6 +1723,13 @@ class XF2xExporter extends AbstractExporter {
                $message = $userRegex->replace($message, $userCallback);
                $message = $quoteRegex->replace($message, $quoteCallback);
                
+               // fix color bbcodes
+               $message = preg_replace_callback('/\[color=rgb\((\d+),\s*(\d+),\s*(\d+)\)\]/i', function ($matches) {
+                       list(, $r, $g, $b) = $matches;
+                       
+                       return sprintf('[color=#%02X%02X%02X]', $r, $g, $b);
+               }, $message);
+               
                // fix size bbcodes
                $message = preg_replace_callback('/\[size=\'?(\d+)(px)?\'?\]/i', function ($matches) {
                        $unit = 'scalar';