took some further steps in implementing gfxdevice.
[swftools.git] / doc / codebeautifier.pl
1 while(<stdin>)
2 {
3     if(/\[CALLPERL\s+(.*)\s+left\]/ ... /\[CALLPERL end\]/) {
4         $lang = $1 if($1);
5         $code .= $_ if(!/CALLPERL/);
6         $name = $1 if(/.flash.*name=([^&][^ ]*)/);
7         $name = $1 if(/.flash.*name=&quot;([^&]*)&quot;/);
8         chomp $name;
9     } 
10     elsif(/\[CALLPERL .*right\]/ ... /\[CALLPERL end\]/) {
11         $highlight .= $_ if(!/CALLPERL/);
12     }
13     elsif ($code ne "" && ($lang eq "swfc" || $lang eq "sc")) {
14         $code =~ s/&quot;/"/g;
15
16 #           print stderr "Warning: ttf->swf\n" if($code =~ s/Arial.ttf/Arial.swf/g);
17
18         open(fi, ">tmp.sc");print fi $code;close(fi);
19         print stderr "[$lang] swfc tmp.sc ($name)\n";
20         system("../src/swfc tmp.sc >&2");
21         ($embed = `swfdump -e $name`) =~ /WIDTH="([^"]*)"/;
22         system("cp $name data");
23         $width = $1;
24         print "<td bgcolor=\"#ffffff\" width=\"$width\">";
25         print $embed;
26         print "</td>";
27         $code="";
28         print;
29         unlink "tmp.sc";
30     }
31     elsif ($code ne "") {
32         $code="";
33     }
34     elsif ($highlight ne "") {
35         $highlight =~ s/^\n\s*//g;
36         $highlight =~ s/\s*\n$//g;
37         print "<pre>\n";
38         # todo: apply syntax highlighting.
39         print $highlight."\n";
40         print "</pre>\n";
41         $highlight="";
42         print;
43     }
44     else {
45         print;
46     }
47 }