jaja
[lectures/dfb-slides.git] / parse.pl
1 #!/usr/bin/perl
2
3 @content=<STDIN>;
4 chomp @content;
5
6 @slide=();
7 @topics=();
8
9 @actions=( "",
10                             "slide top",
11                                 "slide top right",
12                                 "slide top left",
13                                 "slide bottom",
14                                 "slide bottom left",
15                                 "slide bottom right",
16                                 "slide left",
17                                 "slide right");
18
19 print "<?xml version='1.0' encoding='iso-8859-1'?>\n";
20 print "\n<slides bgcolor=\"#000000\" fgcolor=\"#ffffff\" 
21         face=\"../ttf/decker.ttf\" size=\"15\"
22         bullet=\"../img/bullet.png\"
23         screen_width=\"1024\" screen_height=\"768\">\n";
24
25 open(IN,"../head2xml header|") or die "no head2xml / header!!\n";
26 while(<IN>) {
27         print $_;
28 }
29 close(IN);
30
31 foreach(@content) {
32         if((/^\d/) or (/^ \d/)) {
33                 push(@topics,$_);
34         }
35 }
36
37 print "\n<slide effect=\"slide top left, blend\">\n";
38 print "<header size=\"20\" fgcolor=\"#00FF00\">Inhalt</header>\n<text></text>\n";
39 foreach(@topics) {
40         if(/^\d/) {
41                 print "<text></text>\n";
42                 $add="fgcolor=\"#FF0000\"";
43         }
44         else {
45                 $add="";
46         }
47         print "<text $add>$_</text>\n";
48 }
49 print "</slide>\n\n";
50
51 $topic=0;
52
53 push(@content," 23");
54
55 foreach(@content) {
56         s/\#.*//;
57         if(not /^\s+$/) {
58         s/&/&amp;/g;
59         s/</&lt;/;
60         s/>/&gt;/;
61         
62         #s/ue/ü/g;
63         #s/ae/ä/g;
64         #s/oe/ö/g;
65         
66         s/Ue/Ü/g;
67         s/Ae/Ä/g;
68         s/Oe/Ö/g;
69         # unterpunkt
70         if(/^ \d/) {
71                 if(@slide) {
72                         $action=$actions[int(rand($#actions))];
73                         if(length($action)>0) {
74                                 if(int(rand(2))==1) {
75                                         $action.=", blend";
76                                 }
77                         }
78                         else {
79                                 if(int(rand(2))==1) {
80                                         $action.="blend";
81                                 }
82                         }
83                         if(length($action)>0) {
84                                 $action=" effect=\"$action\"";
85                         }
86                         print "<slide$action>\n";
87                         print STDERR "$topics[$topic] $action\n";
88                         print "<header size=\"20\" fgcolor=\"#00FF00\">$topics[$topic]</header>\n<text></text>\n";
89                         foreach(@slide) {
90                                 if(/^  \+ /) {
91                                         s/\+//;
92                                         print "<text></text>\n<listitem fgcolor=\"#0000FF\" size=\"20\">$_</listitem>\n";
93                                 }
94                                 elsif(/ \+ /) {
95                                         s/\+//;
96                                         print "<text></text>\n<listitem size=\"20\">$_</listitem>\n";
97                                 }
98                                 else {
99                                         print "<text>$_</text>\n";
100                                 }
101                         }
102                         print "</slide>\n\n";
103                         #$topic++;
104                 }
105                 @slide=();
106                 $topic++;
107                 $_=$topics[$topic];
108                 if(/^\d/) {
109                         $topic++;
110                 }
111         }
112         # ueberpunkt
113         elsif (/^\d/) {
114                 
115         }
116         # normaler content
117         else {
118                 push(@slide,$_);
119         }
120 }
121 }
122
123 print "</slides>\n";