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