SuperTinyIcons icon indicating copy to clipboard operation
SuperTinyIcons copied to clipboard

Correct the sizes using a script

Open benkasminbullock opened this issue 4 years ago • 0 comments

It would make sense to use a script to update the sizes in README.md.

For the time being I used this script to do the job:

#!/home/ben/software/install/bin/perl
use warnings;
use strict;
use utf8;
use FindBin '$Bin';
use File::Slurper qw!read_text write_text!;
my $url = 'https://edent.github.io/SuperTinyIcons';
my $readme = "$Bin/README.md";
my $text = read_text ($readme);
my $line_re = qr!
    (
	<td>
	.*?
	<br>
	<img\s+src="$url/(.*?)".*
	<br>
	([0-9]+)\s+Bytes
    )!x;

my $check = $text;
$check =~ s!$line_re!!g;
if ($check =~ /(\Q$url\E.*\.svg.*Bytes)/) {
    die "$1 Matches";
}

my $copy = $text;

while ($text =~ m!$line_re!xg) {
    my ($line, $file, $size) = ($1, $2, $3);
    my $nowsize = -s "$Bin/$file";
    if ($size != $nowsize) {
	print "$file $size $nowsize\n";
    }
    my $newline = $line;
    $newline =~ s!\Q$size\E!$nowsize!;
    $copy =~ s!\Q$line\E!$newline!;
}
write_text ($readme, $copy);

benkasminbullock avatar May 19 '21 02:05 benkasminbullock