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