Subversion Repositories wimsdev

Rev

Rev 15612 | Rev 17620 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | RSS feed

  1. #!/usr/bin/perl
  2.  
  3. $nomeprog="make.pl";
  4.  
  5. ##if ( @ARGV != 1 ){
  6. ##    die("usage: \"$nomeprog _nomefile_\n");
  7. ##}
  8.  
  9. my ($filein,$fileout)=@ARGV;
  10.  
  11. $status=0;
  12. $txtoutput="";
  13. @comments=();
  14.  
  15. $setup="xrange -10,10 \nyrange -10,10 \nhline 0,0,black\nvline 0,0,black";
  16. $cellwidth="265";
  17. # $dimsize="200";
  18. $dimsize="400";
  19.  
  20. open (INPUT,"< $filein") || die("Cannot open in $filein: $!\n");
  21. open (OUTPUT,"> $fileout") || die("Cannot open out $fileout: $!\n");
  22.  
  23. print OUTPUT "<h3>Setup</h3>\n";
  24. print OUTPUT "<div><table><tr><td width=\"$cellwidth\"></td>\n<td width=\"$cellwidth\">\n";
  25. print OUTPUT "canvasdraw\n<pre>canvasdraw{$dimsize,$dimsize}{\n$setup\n...\n}</pre>";
  26. print OUTPUT "</td><td width=\"$cellwidth\">\n";
  27. print OUTPUT "flydraw\n<pre>draw{$dimsize,$dimsize}{\n$setup\n...\n}</pre>";
  28. print OUTPUT "</td>\n</tr>\n</table>\n</div>\n";
  29.  
  30. print OUTPUT "<h3>Examples</h3>\n";
  31. my $cnt=0;
  32. while (<INPUT>){
  33.   chop;
  34.   if($cnt==0){ $cnt=1; next};
  35.   my($riga)=$_;
  36.   if ($riga =~ /^:/g){
  37.     if($status == 1){
  38.       print OUTPUT '<h4>' . $comments[1] . "</h4>";
  39.       if($comments[2] ne ""){
  40.         print OUTPUT "($comments[2])\n";
  41.       }
  42.       print OUTPUT "</h4>";
  43.       print OUTPUT '<table class="wimsborder">
  44.        <tr><td colspan="2" style="text-align:left"><pre>' . niceprint($txtoutput) . "</pre>";
  45.       print OUTPUT "\n";
  46.  
  47.       print OUTPUT "</td></tr>\n";
  48.       print OUTPUT "<tr><td width=\"$cellwidth\">\n";
  49.       print OUTPUT "\\canvasdraw{$dimsize,$dimsize}{ \n$setup \n";
  50.       print OUTPUT $txtoutput;
  51.       print OUTPUT "}\n</td>\n<td width=\"$cellwidth\">\n";
  52.       print OUTPUT "\\draw{$dimsize,$dimsize}{ \n$setup \n";
  53.       print OUTPUT $txtoutput;
  54.       print OUTPUT"}\n</td>\n</tr>\n</table>\n";
  55.       $txtoutput="";
  56.     }
  57.     $status=1;
  58.     @comments=split(":",$_);
  59.   } else {
  60.     $txtoutput=$txtoutput."$riga\n";
  61.   }
  62. }
  63.  
  64. sub niceprint {
  65.     my($str) = @_ ;
  66.     $str =~ s/\\filedir/\\\\filedir/g;
  67.     $str =~ s/\$/&\#36;/g ;
  68.     return $str;
  69. }
  70.