Update readme images to contain title attributes

This commit is contained in:
2023-07-25 14:26:03 +03:00
parent a3b2f99f91
commit 06b6b3f274
2 changed files with 2449 additions and 2447 deletions

4844
README.md

File diff suppressed because it is too large Load Diff

View File

@@ -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);