#!/usr/bin/perl
 
## create the file public_html/bases/sys/css_classes from the css of public_html/themes/standard
 
## use in documentation
 
use warnings;
 
use strict;
 
#use Text::Balanced qw (extract_bracketed extract_tagged);
 
 
 
for my $theme ('default','Nikaia','standard'){
 
 my $dir="public_html/themes/$theme";
 
 my $outfile="public_html/bases/sys/css_classes_$theme" ;
 
 my $TEXT="generated by bin/css.pl - do not change by hand \n" ; 
 
 for my $file (glob("$dir/*.css")) {   
  $TEXT  .= "\n\n\n/*generated from file : $file */\n" ;
 
  my $text=treate_file($file) ; 
 
  $TEXT .= "\n$text" ; 
 
 }
 
 for my $file (glob("$dir/*/*.css")) {   
  $TEXT  .= "\n\n\n/*generated from file : $file */\n" ;
 
  my $text=treate_file($file) ; 
 
  $TEXT .= "\n$text" ; 
 
 }
 
 
 
 out($outfile, $TEXT) ;
 
}
 
 
 
sub treate_file { my ($file)=@_;
 
  my $text = <IN>; close(IN
);  
  $text =~ s/\n\t+//g ;
 
  $text =~ s/\n}/}/g ;
 
  $text =~ s/{[^{]+}/{ }/g ;
 
  $text =~ s/{ }(.)/{ }\n$1/g ;
 
  $text ; 
 
  }
 
sub out { my ($bloc, $text) = @_;
 
}