mirror of
https://github.com/ivuorinen/emoji.git
synced 2026-01-26 11:23:58 +00:00
Update readme images to contain title attributes
This commit is contained in:
@@ -2,55 +2,57 @@
|
||||
|
||||
$output = 'README.md';
|
||||
$per_row = 5;
|
||||
$files = glob( 'emoji/*.{png,gif,jpg,jpeg}', GLOB_BRACE );
|
||||
$files = glob('emoji/*.{png,gif,jpg,jpeg}', GLOB_BRACE);
|
||||
$listing = [];
|
||||
$per_row_width = floor( 100 / $per_row ) . '%';
|
||||
$per_row_width = floor(100 / $per_row) . '%';
|
||||
|
||||
sort( $files );
|
||||
sort($files);
|
||||
|
||||
if ( count( $files ) < 1 ) {
|
||||
die( 'No images to continue with.' );
|
||||
if (count($files) < 1) {
|
||||
die('No images to continue with.');
|
||||
}
|
||||
|
||||
function get_basename( string $file ) {
|
||||
$parts = explode( DIRECTORY_SEPARATOR, $file );
|
||||
return end( $parts );
|
||||
function get_basename(string $file)
|
||||
{
|
||||
$parts = explode(DIRECTORY_SEPARATOR, $file);
|
||||
return end($parts);
|
||||
}
|
||||
|
||||
foreach ( $files as $file ) {
|
||||
$first = get_basename( $file );
|
||||
$first = str_replace( 'emoji/', '', $first );
|
||||
$first = trim( $first[0] );
|
||||
foreach ($files as $file) {
|
||||
$first = get_basename($file);
|
||||
$first = str_replace('emoji/', '', $first);
|
||||
$first = trim($first[0]);
|
||||
|
||||
if ( preg_match( '/([^a-zA-Z:])/', $first ) ) {
|
||||
if (preg_match('/([^a-zA-Z:])/', $first)) {
|
||||
$first = '\[^a-zA-Z:\]';
|
||||
}
|
||||
|
||||
if ( ! array_key_exists( $first, $listing ) ) {
|
||||
$listing[ $first ] = [];
|
||||
if (!array_key_exists($first, $listing)) {
|
||||
$listing[$first] = [];
|
||||
}
|
||||
|
||||
$listing[ $first ][] = $file;
|
||||
$listing[$first][] = $file;
|
||||
}
|
||||
|
||||
$contents = "# Emotes\n\n";
|
||||
|
||||
foreach ( $listing as $header => $icons ) {
|
||||
$contents .= sprintf( "## %s\n\n", $header );
|
||||
foreach ($listing as $header => $icons) {
|
||||
$contents .= sprintf("## %s\n\n", $header);
|
||||
|
||||
$chunks = array_chunk( $icons, $per_row );
|
||||
$chunks = array_chunk($icons, $per_row);
|
||||
|
||||
$contents .= '<table style="text-align: center;width: 100%">' . "\n";
|
||||
|
||||
foreach ( $chunks as $chunk_icons ) {
|
||||
foreach ($chunks as $chunk_icons) {
|
||||
$contents .= "<tr>\n";
|
||||
|
||||
foreach ( $chunk_icons as $icon ) {
|
||||
foreach ($chunk_icons as $icon) {
|
||||
$file = $icon;
|
||||
[ $name, $ext ] = explode( '.', get_basename($icon), 2 );
|
||||
[$name, $ext] = explode('.', get_basename($icon), 2);
|
||||
|
||||
$format = '<td style=\'width: %s\'><img width=\'30\' src="%2$s" alt="%2$s"><br><kbd>:%3$s:</kbd></td>';
|
||||
$contents .= sprintf( $format, $per_row_width, $file, $name ) . "\n";
|
||||
$format = '<td style=\'width: %s\'><img width=\'30\' src="%2$s"'
|
||||
. ' alt="%2$s" title=":%3$s:"><br><kbd>:%3$s:</kbd></td>';
|
||||
$contents .= sprintf($format, $per_row_width, $file, $name) . "\n";
|
||||
}
|
||||
|
||||
$contents .= "</tr>\n";
|
||||
@@ -61,4 +63,4 @@ foreach ( $listing as $header => $icons ) {
|
||||
|
||||
$contents .= "\n\n Generated: " . date('c');
|
||||
|
||||
file_put_contents( $output, $contents );
|
||||
file_put_contents($output, $contents);
|
||||
|
||||
Reference in New Issue
Block a user