-
-
Notifications
You must be signed in to change notification settings - Fork 310
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Shorten colors some more if their color name is shorter
As suggested on issue #109
- Loading branch information
1 parent
1a15254
commit 3253a81
Showing
2 changed files
with
40 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -487,7 +487,38 @@ protected function shortenHex($content) | |
{ | ||
$content = preg_replace('/(?<![\'"])#([0-9a-z])\\1([0-9a-z])\\2([0-9a-z])\\3(?![\'"])/i', '#$1$2$3', $content); | ||
|
||
return $content; | ||
// we can shorten some even more by replacing them with their color name | ||
$colors = array( | ||
'#F0FFFF' => 'azure', | ||
'#F5F5DC' => 'beige', | ||
'#A52A2A' => 'brown', | ||
'#FF7F50' => 'coral', | ||
'#FFD700' => 'gold', | ||
'#808080' => 'gray', | ||
'#008000' => 'green', | ||
'#4B0082' => 'indigo', | ||
'#FFFFF0' => 'ivory', | ||
'#F0E68C' => 'khaki', | ||
'#FAF0E6' => 'linen', | ||
'#800000' => 'maroon', | ||
'#000080' => 'navy', | ||
'#808000' => 'olive', | ||
'#CD853F' => 'peru', | ||
'#FFC0CB' => 'pink', | ||
'#DDA0DD' => 'plum', | ||
'#800080' => 'purple', | ||
'#F00' => 'red', | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
matthiasmullie
Author
Owner
|
||
'#FA8072' => 'salmon', | ||
'#A0522D' => 'sienna', | ||
'#C0C0C0' => 'silver', | ||
'#FFFAFA' => 'snow', | ||
'#D2B48C' => 'tan', | ||
'#FF6347' => 'tomato', | ||
'#EE82EE' => 'violet', | ||
'#F5DEB3' => 'wheat', | ||
); | ||
|
||
return str_ireplace(array_keys($colors), $colors, $content); | ||
} | ||
|
||
/** | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
I believe this line is wrong, for example border: 1px solid #f00000; is becoming border: 1px solid red000;