fixed kdtree duplicate reporting problem
[swftools.git] / doc / codebeautifier.pl
blob169b23c226a4a1950bed0c3ccc99a2117bda2406
1 $nr = 1;
2 while(<stdin>)
4 if(/\[CALLPERL\s+(.*)\s+left\]/ ... /\[CALLPERL end\]/) {
5 $lang = $1 if($1);
6 $code .= $_ if(!/CALLPERL/);
7 $name = $1 if(/.flash.*name=([^&][^ ]*)/);
8 $name = $1 if(/.flash.*name=&quot;([^&]*)&quot;/);
9 chomp $name;
11 elsif(/\[CALLPERL .*right\]/ ... /\[CALLPERL end\]/) {
12 $highlight .= $_ if(!/CALLPERL/);
14 elsif ($code ne "" && ($lang eq "swfc" || $lang eq "sc")) {
15 $code =~ s/&quot;/"/g;
17 # print stderr "Warning: ttf->swf\n" if($code =~ s/Arial.ttf/Arial.swf/g);
19 open(fi, ">tmp.sc");print fi $code;close(fi);
20 print stderr "[$lang] swfc tmp.sc ($name)\n";
21 system("../src/swfc tmp.sc >&2");
22 ($embed = `swfdump -e $name`) =~ /WIDTH="([^"]*)"/;
23 system("cp $name data");
24 $width = $1;
25 print "<td bgcolor=\"#ffffff\" width=\"$width\">";
26 print $embed;
27 print "</td>";
28 $code="";
29 print;
30 unlink "tmp.sc";
32 elsif ($code ne "" && ($lang eq "python" or $lang eq "shell")) {
33 $code =~ s/&quot;/"/g;
34 if($lang eq "python") {
35 open(fi, ">$nr.py");print fi $code;close(fi);
36 $nr = $nr + 1;
38 print "<td bgcolor=\"#ffffff\" width=\"$width\">";
39 print $embed;
40 print "</td>";
41 $code="";
42 print;
44 elsif ($code ne "") {
45 $code="";
47 elsif ($highlight ne "") {
48 $highlight =~ s/^\n\s*//g;
49 $highlight =~ s/\s*\n$//g;
50 print "<pre>\n";
51 # todo: apply syntax highlighting.
52 print $highlight."\n";
53 print "</pre>\n";
54 $highlight="";
55 print;
57 else {
58 print;