Data-Table-Text

 view release on metacpan or  search on metacpan

lib/Data/Table/Text.pm  view on Meta::CPAN


sub postProcessImagesForDocumentation(%)                                        # Post process svg images into png and reload into repo for use by documentation. Useful for detailed svg images which can take a long time to load into a browser - it tr...
 {my (%options) = @_;                                                           # Options
  my $log   = $options{log}  // 1;                                              # Show actions if true
  my $size  = $options{size} // 4096;                                           # Longest size of png images to produce from svg
  my $home  = currentDirectory;                                                 # Home folder
  my $dir   = $options{target}  // fpd qw(lib Silicon Chip);                    # Target folder for images
  my $imgs  = fpd $home, $dir;                                                  # Images source folder
     $imgs  = $home if $ENV{GITHUB_TOKEN};                                      # Change folders for github
  my $svg   = fpd $imgs, qw(svg);                                               # Svg folder
  my $png   = fpd $imgs, qw(png);                                               # Png folder
  my ($user, $repo) =  split m(/), $ENV{GITHUB_REPOSITORY}//'';                 # Userid and repo from github

  makePath($png);                                                               # Make png folder

  my @f = searchDirectoryTreesForMatchingFiles $svg, qw(.svg);                  # Svg files from which we make png files

  my @r;                                                                        # Results
  for my $s(@f)                                                                 # Svg files
   {my $t = setFileExtension $s, q(png);
       $t = swapFilePrefix $t, $svg, $png;                                      # Matching png

lib/Data/Table/Text.pm  view on Meta::CPAN

            my $u = "$svg$s.svg";                                               # Implied svg file url
               $u = "$png$s.png" if $p;                                         # Implied png file url
            push @svg, qq(\n\n=for html <img src="$u">) unless $svg{$u}++;      # The new line takes the directive out of an example.  Only include images otherwise the document gets very big very quickly
            for my $i(1..99)                                                    # Test for svgs that already exist
             {my $u = "$svg${s}_$i.svg";                                        # File name url
                 $u = "$png${s}_$i.png" if $p;                                  # Implied png file url
              my $f = "svg/${s}_$i.svg";                                        # Local svg file name
              last unless -e $f;                                                # Include file if it exists locally
              push @svg, qq(\n\n=for html <img src="$u">) unless $svg{$u}++;    # The new line takes the directive out of an example.  Only include images otherwise the document gets very big very quickly
             }
            if (defined $p)                                                     # Png count
             {for my $i(1..$p)                                                  # Add any additional svgs
               {my $u = "$png${s}_$i.png";                                      # Png url
                push @svg, qq(\n\n=for html <img src="$u">) unless $svg{$u}++;  # The new line takes the directive out of an example.  Only include images otherwise the document gets very big very quickly
               }
             }
           }
         }
        push @testLines, @svg;
       }

      push @testLines, '';                                                      # Blank line between each test line



( run in 0.952 second using v1.01-cache-2.11-cpan-0a6323c29d9 )