@@ -484,7 +484,7 @@ protected function move(ConverterInterface $converter, $content)
484
484
/**
485
485
* Shorthand HEX color codes.
486
486
* #FF0000FF -> #f00 -> red
487
- * #FF00FF00 -> transparent
487
+ * #FF00FF00 -> transparent.
488
488
*
489
489
* @param string $content The CSS content to shorten the HEX color codes for
490
490
*
@@ -504,13 +504,13 @@ protected function shortenHexColors($content)
504
504
505
505
$ colors = array (
506
506
// make these more readable
507
- '#00f ' => 'blue ' ,
507
+ '#00f ' => 'blue ' ,
508
508
'#dc143c ' => 'crimson ' ,
509
- '#0ff ' => 'cyan ' ,
509
+ '#0ff ' => 'cyan ' ,
510
510
'#8b0000 ' => 'darkred ' ,
511
511
'#696969 ' => 'dimgray ' ,
512
512
'#ff69b4 ' => 'hotpink ' ,
513
- '#0f0 ' => 'lime ' ,
513
+ '#0f0 ' => 'lime ' ,
514
514
'#fdf5e6 ' => 'oldlace ' ,
515
515
'#87ceeb ' => 'skyblue ' ,
516
516
'#d8bfd8 ' => 'thistle ' ,
@@ -536,7 +536,7 @@ protected function shortenHexColors($content)
536
536
'#ffc0cb ' => 'pink ' ,
537
537
'#dda0dd ' => 'plum ' ,
538
538
'#800080 ' => 'purple ' ,
539
- '#f00 ' => 'red ' ,
539
+ '#f00 ' => 'red ' ,
540
540
'#fa8072 ' => 'salmon ' ,
541
541
'#a0522d ' => 'sienna ' ,
542
542
'#c0c0c0 ' => 'silver ' ,
@@ -547,13 +547,13 @@ protected function shortenHexColors($content)
547
547
'#ee82ee ' => 'violet ' ,
548
548
'#f5deb3 ' => 'wheat ' ,
549
549
// or the other way around
550
- 'black ' => '#000 ' ,
550
+ 'black ' => '#000 ' ,
551
551
'fuchsia ' => '#f0f ' ,
552
552
'magenta ' => '#f0f ' ,
553
- 'white ' => '#fff ' ,
554
- 'yellow ' => '#ff0 ' ,
553
+ 'white ' => '#fff ' ,
554
+ 'yellow ' => '#ff0 ' ,
555
555
// and also `transparent`
556
- 'transparent ' => '#fff0 '
556
+ 'transparent ' => '#fff0 ' ,
557
557
);
558
558
559
559
return preg_replace_callback (
@@ -587,12 +587,12 @@ protected function convertLegacyColors($content)
587
587
$ content = preg_replace ('/(rgb|hsl)a?\(([^,\s]+)\s*,\s*([^,\s]+)\s*,\s*([^,\s]+)\)/i ' , '$1($2 $3 $4) ' , $ content );
588
588
589
589
// convert `rgb` to `hex`
590
- $ dec = '([01]?[0-9]?[0-9]|2[0-4][0-9]|25[0-5]) ' ;// [000-255] THX @ https://www.regular-expressions.info/numericranges.html
590
+ $ dec = '([01]?[0-9]?[0-9]|2[0-4][0-9]|25[0-5]) ' ; // [000-255] THX @ https://www.regular-expressions.info/numericranges.html
591
+
591
592
return preg_replace_callback (
592
593
"/rgb\( $ dec $ dec $ dec\)/i " ,
593
- function ($ match )
594
- {
595
- return sprintf ('#%02x%02x%02x ' , $ match [1 ],$ match [2 ],$ match [3 ]);
594
+ function ($ match ) {
595
+ return sprintf ('#%02x%02x%02x ' , $ match [1 ], $ match [2 ], $ match [3 ]);
596
596
},
597
597
$ content
598
598
);
@@ -620,10 +620,10 @@ protected function cleanupModernColors($content)
620
620
$ tag = '(rgb|hsl|hwb|(?:(?:ok)?(?:lch|lab))) ' ;
621
621
622
622
// remove alpha channel if it's pointless ..
623
- $ content = preg_replace ('/ ' . $ tag. '\(([^\s]+)\s+([^\s]+)\s+([^\s]+)\s+\/\s+1(?:[\.\d]*|00%)?\)/i ' , '$1($2 $3 $4) ' , $ content );
623
+ $ content = preg_replace ('/ ' . $ tag . '\(([^\s]+)\s+([^\s]+)\s+([^\s]+)\s+\/\s+1(?:[\.\d]*|00%)?\)/i ' , '$1($2 $3 $4) ' , $ content );
624
624
625
625
// replace `transparent` with shortcut ..
626
- $ content = preg_replace ('/ ' . $ tag. '\([^\s]+\s+[^\s]+\s+[^\s]+\s+\/\s+0(?:[\.0%]*)?\)/i ' , '#fff0 ' , $ content );
626
+ $ content = preg_replace ('/ ' . $ tag . '\([^\s]+\s+[^\s]+\s+[^\s]+\s+\/\s+0(?:[\.0%]*)?\)/i ' , '#fff0 ' , $ content );
627
627
628
628
return $ content ;
629
629
}
0 commit comments