#!/usr/bin/perl
my $nom = "$ARGV[0]";
open (FILE, $nom);
$nom =~ s/.tex/-sol.cas/;
open (SORTIE, ">$nom");
#
my $l="";
while (<FILE>){
    next unless /^\%/; 
    $_=~ s/^\%//;
    next unless !/^\%/; 
#
$l = $l.$_
;}
my @F=split(/ *!s!/,"$l");
foreach (@F){
    if ($_ =~ m/<[cmpgh]>/){my $r = int(split(/\n/,$_)*14.5); my $ret = $r-1;
	if ($_ =~ m/<m>/){
			  $_ =~ s/ *<m>.*\n//;chop;;$_ = $_."\n";}
	if ($_ =~ m/<c>/){print SORTIE  "/* ";
		      $_ =~ s/ *<c>.*\n//;$_ =~ tr/\n/£/;chop;$_ = $_."*/\n";}
	if ($_ =~ m/<p>/){
	    $_ =~ s/ *<p>.*\n//; }
    if ($_ =~ m/<g>/){
                    $_ =~ s/ *<g>.*\n//;
		      		      $_="";}
    if ($_ =~ m/<h>/){
                    $_ =~ s/ *<h>.*\n//;
		      		      $_="";}
			   print SORTIE  "$_";}
    else {$_ =~ s/^\n//;
    print SORTIE  "$_";}
}


