@@ -495,11 +495,11 @@ protected function shortenHexColors($content)
495495 $ content = preg_replace ('/#([0-9a-f]) \\1([0-9a-f]) \\2([0-9a-f]) \\3(?:([0-9a-f]) \\4)?/i ' , '#$1$2$3$4 ' , $ content );
496496
497497 // remove alpha channel if it's pointless ..
498- $ content = preg_replace ('/#([0-9a-f]{6})ff/i ' , '#$1 ' , $ content );
499- $ content = preg_replace ('/#([0-9a-f]{3})f/i ' , '#$1 ' , $ content );
498+ $ content = preg_replace ('/#([0-9a-f]{6})ff/i ' , '#$1 ' , $ content );
499+ $ content = preg_replace ('/#([0-9a-f]{3})f(?=[ ;}\)]) /i ' , '#$1 ' , $ content );
500500
501501 // replace `transparent` with shortcut ..
502- $ content = preg_replace ('/#[0-9a-f]{6}00/i ' , '#0000 ' , $ content );
502+ $ content = preg_replace ('/#[0-9a-f]{6}00/i ' , '#fff0 ' , $ content );
503503
504504 $ colors = array (
505505 // make these more readable
@@ -552,7 +552,7 @@ protected function shortenHexColors($content)
552552 'white ' => '#fff ' ,
553553 'yellow ' => '#ff0 ' ,
554554 // and also `transparent`
555- # 'transparent' => '#0000' CHECK safari
555+ 'transparent ' => '#fff0 '
556556 );
557557
558558 return preg_replace_callback (
@@ -581,10 +581,10 @@ protected function shortenRGBColors($content)
581581 $ dec = '([01]?[0-9]?[0-9]|2[0-4][0-9]|25[0-5]) ' ;// [000-255]
582582
583583 // remove alpha channel if it's pointless ..
584- $ content = preg_replace (" /(rgb)a?\(([^,\s]+)[,\s]([^,\s]+)[,\s]([^,\s]+)\s?[,\/]\s?1(?:[\.\d]*|00%)?\)/i " , '$1($2 $3 $4) ' , $ content );
584+ $ content = preg_replace (' /(rgb)a?\(([^,\s]+)[,\s]([^,\s]+)[,\s]([^,\s]+)\s?[,\/]\s?1(?:[\.\d]*|00%)?\)/i ' , '$1($2 $3 $4) ' , $ content );
585585
586586 // replace `transparent` with shortcut ..
587- # $content = preg_replace(" /rgba?\([^,\s]+[,\s][^,\s]+[,\s][^,\s]+\s?[,\/]\s?0(?:[\.0%]*)?\)/i" , '#0000 ', $content); CHECK safari
587+ $ content = preg_replace (' /rgba?\([^,\s]+[,\s][^,\s]+[,\s][^,\s]+\s?[,\/]\s?0(?:[\.0%]*)?\)/i ' , '#fff0 ' , $ content );
588588
589589 return preg_replace_callback (
590590 "/rgb\( $ dec [,\s]$ dec [,\s]$ dec\)/i " ,
@@ -612,10 +612,10 @@ protected function cleanupNEWColors($content)
612612 $ pct = '((100(?:\.0+)|0?[0-9]?[0-9])(\.[0-9]+)%) ' ;// [000.*-100] %
613613
614614 // remove alpha channel if it's pointless ..
615- $ content = preg_replace (" /(hsl)a?\(([^,\s]+)[,\s]([^,\s]+)[,\s]([^,\s]+)\s?[,\/]\s?1(?:[\.\d]*|00%)?\)/i " , '$1($2 $3 $4) ' , $ content );
615+ $ content = preg_replace (' /(hsl)a?\(([^,\s]+)[,\s]([^,\s]+)[,\s]([^,\s]+)\s?[,\/]\s?1(?:[\.\d]*|00%)?\)/i ' , '$1($2 $3 $4) ' , $ content );
616616
617617 // replace `transparent` with shortcut ..
618- # $content = preg_replace(" /hsla?\([^,\s]+[,\s][^,\s]+[,\s][^,\s]+\s?[,\/]\s?0(?:[\.0%]*)?\)/i" , '#0000 ', $content); CHECK safari
618+ $ content = preg_replace (' /hsla?\([^,\s]+[,\s][^,\s]+[,\s][^,\s]+\s?[,\/]\s?0(?:[\.0%]*)?\)/i ' , '#fff0 ' , $ content );
619619
620620 # ToRGB ?: https://github.com/mexitek/phpColors/blob/a74808eaf7cd918681aab0cd30f142025556bc8a/src/Mexitek/PHPColors/Color.php#L124
621621 #"/(hsl)a?\($hue[,\s]$pct[,\s]$pct[,\/]1(?:[\.\d]*|00%)?\)/i"
@@ -628,10 +628,10 @@ protected function cleanupNEWColors($content)
628628 */
629629
630630 // remove alpha channel if it's pointless ..
631- $ content = preg_replace (" /(lch|lab|hwba?)\(([^\s]+)\s([^\s]+)\s([^\s]+)\s?\/\s?1(?:[\.\d]*|00%)?\)/i " , '$1($2 $3 $4) ' , $ content );
631+ $ content = preg_replace (' /(lch|lab|hwba?)\(([^\s]+)\s([^\s]+)\s([^\s]+)\s?\/\s?1(?:[\.\d]*|00%)?\)/i ' , '$1($2 $3 $4) ' , $ content );
632632
633633 // replace `transparent` with shortcut ..
634- # $content = preg_replace(" /(lch|lab)\([^\s]+\s[^\s]+\s[^\s]+\s?\/\s?0(?:[\.0%]*)?\)/i" , '#0000 ', $content); CHECK safari
634+ $ content = preg_replace (' /(lch|lab)\([^\s]+\s[^\s]+\s[^\s]+\s?\/\s?0(?:[\.0%]*)?\)/i ' , '#fff0 ' , $ content );
635635
636636 #"/(hwb)a?\($hue\s$pct\s$pct\s?\/\s?1(?:[\.\d]*|00%)?\)/i"
637637 #"/(lch|lab)\($pct\s$VAR\s$VAR\s?\/\s?1(?:[\.\d]*|00%)?\)/i"
0 commit comments