/[PLies]/burst.pl
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Contents of /burst.pl

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.21 - (show annotations)
Tue Sep 18 12:50:15 2001 UTC (22 years, 6 months ago) by dpavlin
Branch: MAIN
CVS Tags: HEAD
Changes since 1.20: +3 -2 lines
File MIME type: text/plain
don't put extra nl(s) in debug output

1 #!/usr/bin/perl
2 #
3 # PLies Copyright 2001 Dobrica Pavlinusic <dpavlin@rot13.org>
4 #
5 # this tool is based on SlideMaker and XLSies tool
6 # split a all.htm into slide*.htm
7 #
8 # For more information please see presentation about this tool on
9 # http://www.rot13.org/~dpavlin/presentations/XLSies_to_PLies/
10 #
11 # Copyright 1999 World Wide Web Consortium,
12 # (Massachusetts Institute of Technology, Institut
13 # National de Recherche en Informatique et en
14 # Automatique, Keio University). All Rights Reserved.
15 # This program is distributed under the W3C's
16 # Intellectual Property License. This program is
17 # distributed in the hope that it will be useful, but
18 # WITHOUT ANY WARRANTY; without even the implied
19 # warranty of MERCHANTABILITY or FITNESS FOR A
20 # PARTICULAR PURPOSE. See W3C License
21 # http://www.w3.org/Consortium/Legal/ for more details.
22 #
23 #
24 ##############################################################################
25 #
26 # slidemaker credits:
27 #
28 # Stephan Montigaud - stephan@w3.org
29 # created 970601
30 # modified by Pierre Fillault
31 # check the documentation at http://www.w3.org/Talks/YYMMsub/
32 #
33 # modified 19990505 Bert Bos: ALT text of prev/next arrows is now
34 # "prev"/"next" rather than the title of the prev/next slide; looks better
35 # in lynx.
36 #
37 # version: 4.14 - 19990719
38 # $Id: w3cburst.pl,v 1.41 1999/11/02 17:25:50 charles Exp $
39 #
40 #
41 # XLSies credits:
42 #
43 # Sami Lempinen - lempinen@iki.fi
44 # http://www.snowman.sgic.fi/ssl/xslies/
45 #
46 # Text::FastTemplate:
47 # Robert Lehr - bozzio@the-lehrs.com
48
49 use Text::FastTemplate;
50
51 ##############################################################################
52 ## default values of variables
53 ##
54
55 ## show debug output
56 my $debug=0;
57
58 ## default DOCTYPE added on the slides
59 $doctype = '<html xmlns="http://www.w3.org/TR/REC-html40">';
60
61 ## name of raw HTML file containing the slides
62 $all = 'all.htm';
63
64 ## table of content built from all.htm - also first page of the presentation
65 ## this is only the basename as we need to generate one toc for each style sheets
66 ## the main toc will not bear any more so the server can understand a request for '/'
67 ## the next ones will bear a number corresponding to the slide index
68 #$overview = 'Overview';
69 $overview = 'index';
70
71 ## name of the file containing the parameters of the presentation
72 $infos = 'infos.txt';
73
74 ## link to the logo printed on all the slides
75 $logoLink = '';
76
77 ## default location of the logo - works when slidemaker is used as a package
78 $logoFile = '';
79
80 ### localization
81 $loc_toc = "Table of contents";
82 $loc_by = "by";
83 $loc_amp = "&amp;"; # author separator
84 $loc_slide = "Slide";
85 $loc_of = "of"; # $loc_slide nr $loc_of total
86
87 ## alternate representation of the logo
88 $logoAlt = '';
89
90 ## default values set to none
91 $logoLink2 = ''; # link to a potential second reference
92 $logoFile2 = ''; # location of a second logo
93 $logoAlt2 = ''; # alternate representation of the second logo
94
95 ## default accesskeys for navigation icons used in the slides
96 $prevKey = 'P'; # accesskey for previous slide
97 $nextKey = 'N'; # accesskey for next slide
98 $tocKey = 'C'; # accesskey for table of contents
99 $styleKey = 'S'; # accesskey for changing style sheets
100
101 ## default author name
102 $author = 'Staff';
103
104 ## default presentation title
105 $talkTitle = 'Talk';
106
107 ## standard style sheets
108 $cssStandard = '../PLies/css/default.css';
109
110 ## template name
111 $template = '../PLies/default';
112
113 ## default charset use in meta tag http-equiv (undef to skip)
114 #$charset = 'ISO-8859-1';
115
116 ## default <body> tag
117 $body = '<body>';
118
119 ## number of entries on each TOC page
120 $toc_on_page = 10;
121
122 ## use progress bar
123 $progress_bar = 1;
124
125 ## content hight for each slide
126 $content_hight = "70%";
127
128 ## end of default values for the presentation
129 ##############################################################################
130
131 ## globals
132 my $last_toc_title;
133 my %page_data;
134 my %overview_data;
135
136 my $pack = 0;
137 my @pack_additional; # additional files to pack (pictures, logos...)
138 my %nesttag = init_nesttag();
139
140 ##############################################################################
141 ## reading user input from $infos
142 ##
143 my @file;
144
145 ##############################################################################
146 sub parse_infos {
147 my @file=@_;
148 do {
149 if ($file[0] && $file[0] =~ /^[^#\n\r]/) {
150 $file[0] =~ s/\n//; # remove UNIX \n
151 $file[0] =~ s/\r//; # remove WINDOWS \r
152 my ($var,$value) = split(/ *= */,$file[0],2);
153 $value=~s/'/\\'/g;
154 $cmd="\$$var = \'$value\';";
155 if (defined($value)) {
156 eval($cmd) || warn "problem with eval of: $cmd";
157 } else {
158 die "no value defined for $var";
159 }
160 print STDERR "$file[0]\n";
161 }
162 } while (shift(@file));
163 }
164 ##############################################################################
165
166 parse_infos(@ARGV); # backward compatibility and for pack
167
168 # read parameters from infos.txt and put them in @PARAM
169 if (open(INFOS, $infos)) {
170 print STDERR "--- Reading parameters file $infos ---\n";
171 @file = <INFOS>;
172 parse_infos(@file);
173 }
174
175 # try to read local infos.txt for template
176 if (-f "$template/$infos" && open(INFOS,"$template/$infos")) {
177 print STDERR "--- Reading template parameters file $template/$infos ---\n";
178 @file = <INFOS>;
179 parse_infos(@file);
180 close(INFOS);
181 }
182
183 ## @PARAM is now a table with the user preferences for his presentation
184
185 ## use charset
186
187 if ($charset) {
188 $http_equiv='<meta http-equiv="Content-type" content="text/html; charset='.$charset.'">';
189 } else {
190 $http_equiv='';
191 }
192
193
194 ##############################################################################
195 ## read the raw html presentation
196 ##
197
198 ## copy file in memory
199 my $sep = $/;
200 $/ = undef;
201 open(ALL, $all) || die "Error: Cannot open file: $all";
202 my $buf = <ALL>;
203 $buf =~ s/\r//g; # remove WINDOWS \r
204 close(ALL);
205 $/ = $sep;
206
207 ## Remove comments from the raw presentation
208 ## they do not need to show up on the slides
209 $buf =~ s/<!--.*?-->//sgo;
210
211 ## if $pack is set, output name of css (for inclusion in archive), but
212 ## reset $cssStandard only to filename (without path)
213
214 if ($pack) {
215 push @pack_additional,$cssStandard;
216 $cssStandard =~ s/^.*\/([^\/]+)$/$1/g;
217 }
218
219 ## the slidemaker tool assumes that each slide is self contained between 2 sets of h1 tags
220 ## if not it will generate a rather weird output
221 ## split using <h1...> and </h1...> as separator (ignores attributes!)
222 ## h1 or H1 can be used
223 @table = split(/<\/?[hH]1[^>]*>/, $buf);
224
225 ## compute the total number of slides
226 $total = $#table / 2;
227 if ($#table % 2 != 0) {
228 $total = ($#table +1)/2;
229 }
230
231 ##
232 ## raw presentation has been read successfully
233 ##############################################################################
234
235 ##############################################################################
236 ## processing the slides
237
238 print STDERR "\n--- Processing $total slides ---\n";
239
240 ## generate the header table of content of the presentation
241 ## which is also the first page of the talk
242 &openOverview($overview);
243
244 ## start the slide count so we can number them
245 $slideCount = 1;
246
247 ## pre-load template slides using $template dir
248 Text::FastTemplate->defaults(
249 path => [ $template ]
250 );
251
252 Text::FastTemplate->preload( [
253 { file => 'slide.html', key => 'slide' },
254 { file => 'overview.html', key => 'overview' },
255 { file => 'title.html', key => 'title' },
256 ]);
257
258 ## unroll relative anchors (#something) into links with slides
259
260 my %anchor_on_slide;
261
262 ## step 1: record anchors
263 for($i=0; $i<$total; $i++) {
264 my $tmp = $table[($i*2)].$table[($i*2)+1];
265 while ($tmp =~ s,<a +name="*([^>"]+)"*>,,i) {
266 $anchor_on_slide{$1}=($i+1);
267 print STDERR "\tslide ",($i+1)," anchor: $1\n" if ($debug);
268 }
269 }
270
271 ## step 2: fix links
272 for($i=0; $i<$total; $i++) {
273 foreach (keys %anchor_on_slide) {
274 $table[($i*2)] =~ s,href="*#$_"*>,href="slide$anchor_on_slide{$_}\.html#$_">,gi;
275 }
276 }
277
278 ## @table is the array containing each slide with its title
279 ## for each slide to be generated
280 ## we delete each slide and its title when generated
281 ## so that the current slide and its title are always at $table[0] (for the title)
282 ## and $table[1] (for the slide content)
283
284 undef $prev_title;
285 undef $next_title;
286
287 do {
288
289 ## get rid of the first element contained by the raw presentation array
290 shift(@table);
291 ## then $table[0] is the title of the slide to be generated
292 $table[0] =~ s/\n+/ /g; ## replace return character by a white space
293 $table[0] =~ s/\r+/ /g; ## replace lf character by a white space
294 $table[0] =~ s/ +/ /g; ## concatenate several white spaces to only one
295 $table[0] =~ s/^ //; ## remove all the starting white spaces in the title
296 $table[0] =~ s/ $//; ## remove all trailing white spaces in the title
297 ## $slideTitle preserves link(s) in the title
298 $slideTitle = $table[0];
299 ## need to check if the title contains any anchor
300 ## if so it needs to be removed
301 ## because the title is being used in the table of content to link to the corresponding slide
302 $table[0] = remove_anchor($table[0]);
303
304 ## grab next slide title $table[2] (if there's a next slide)
305 ## to be able to use in the 'next' navigation button
306 ## keep in mind that $table[1] contains the slide corresponding to the title $table[0]
307 if ($table[2]) {
308 $next_title= remove_anchor($table[2]);
309 }
310
311 ## the current slide content is stored $table[1]
312 ## there is an attempt to make sure it's clean HTML
313 ## Pierre Fillault's note: use same piece of as used in http://www.w3.org/Web/Tools/CvsCommitScripting
314 ## to make use of the validation service
315 $slideContent = &clean_html($table[1]) ;
316
317 ## extract slide Sub Title <h2>
318 undef $slideSubTitle;
319 if ($slideContent =~ s/<[hH]2[^>]*>(.+)<\/[hH]2[^>]*>//sm) {
320 $slideSubTitle=remove_anchor($1);
321 }
322
323 ## add the title of the current slide to the table of content
324 &addTitle($slideTitle,$slideSubTitle,$slideCount);
325
326 ## generate the current slide
327 ## parameters are:
328 ## title of the slide, its content, the slide number, the title of the previous slide and the title of the next slide
329 &createSlide($slideTitle,$slideSubTitle,$slideContent ,$slideCount++,$prev_title,$next_title);
330
331 ## save the title of the previous slide to be displayed in the 'previous' navigation button
332 $prev_title=remove_anchor($table[0]);
333 }
334 ## process the next slide
335 while (shift(@table));
336
337 ## close the table of content
338 &closeOverview;
339
340 ## generate more toc with the all the style sheets
341 ## as there's no way of loading a style sheet
342 ## except dynamically, but that would be slow
343 ## and would not work on all platforms (ie would fail on Joe's laptop)
344 &generateTOC;
345
346 ## print additional files to pack
347 print STDOUT join("\n",@pack_additional) if ($pack);
348
349 print STDERR "--- Finished ---\n";
350 exit 0;
351 ##
352 ## end of the slidemaker main program
353 ##############################################################################
354
355
356 ##############################################################################
357 ## generate the header of the table of content
358
359 sub openOverview
360 {
361 ## open the file to write to
362 open(FOO, ">$_[0].html") || die "can't open $_[0].html: $!";
363 push @pack_additional,"$_[0].html" if ($pack);
364
365 ## the style sheet used in the table of content is
366 $stylelink = "";
367 ## here is the standard style sheet
368 $stylelink .= "<link href=\"$cssStandard\" rel=\"stylesheet\" type=\"text/css\" title=\"Talk\" media=\"screen\">";
369
370 %overview_data = (
371 doctype => $doctype,
372 title => $title,
373 http_equiv => $http_equiv,
374 stylelink => $stylelink,
375 body => $body,
376
377 logoLink => $logoLink,
378 logoFile => $logoFile,
379 logoAlt => $logoAlt,
380 logoLink2 => $logoLink2,
381 logoFile2 => $logoFile2,
382 logoAlt2 => $logoAlt2,
383
384 talkTitle => $talkTitle,
385 talkSubTitle => $talkSubTitle,
386
387 content_hight => $content_hight,
388
389 author => $author,
390 authorUrl => $authorUrl,
391 author2 => $author2,
392 author2Url => $author2Url,
393
394 date => $date,
395
396 toc_title => $loc_toc,
397 template_dir => "$template/",
398 );
399
400 }
401 ##
402 ## the beginning of the table of content has been generated and saved
403 ##############################################################################
404
405 ##############################################################################
406 ## generate the footer of the table of content
407
408 sub closeOverview
409 {
410 $overview_data{slide_html} = make_progress_bar(0,$total);
411 $overview_data{toc_entries} = [ @toc_entries ];
412
413 my $page= new Text::FastTemplate key => 'overview';
414 $page_data{template_dir}='' if ($pack);
415 print FOO $page->output( \%overview_data );
416
417 close(FOO);
418 }
419 ##
420 ## the toc has been completed and saved
421 ##############################################################################
422
423 ##############################################################################
424 ## add an item in the toc
425
426 sub addTitle
427 {
428 my ($title,$subtitle,$nr) = @_;
429 $title =~ s/\r//ig; # remove the windows CR+LF
430 $title =~ s/<[^>]+>//g;
431 $subtitle =~ s/<[^>]+>//g;
432
433 if (! $title) {
434 return 1;
435 }
436
437 # split TOC entries to multiple pages
438
439 if ($nr % $toc_on_page == 0) {
440 my $toc_nr=int($nr/$toc_on_page);
441
442 $item = {
443 pre_html => $pre_ul,
444 accesskey => " ", # space
445 href => "index-toc$toc_nr.html",
446 title => "...",
447 post_html => $post_ul,
448 more => 1, # use style for more pages link (...)
449 };
450 push @toc_entries, $item;
451
452 &closeOverview;
453 undef @toc_entries;
454 &openOverview("$overview-toc$toc_nr");
455 $last_toc_title='';
456 }
457
458 $pre_ul=$post_ul='';
459 if ($last_toc_title eq $title && $subtitle) {
460 $title = $subtitle;
461 $pre_ul='<ul>';
462 $post_ul='</ul>';
463 } else {
464 $last_toc_title=$title;
465 }
466
467 # add accesskey for first 9 slides (`1' - `9') or just for first
468 # TOC page, and tabindex for all slides
469 if ($nr < 10 && $nr < $toc_on_page) {
470 $item = {
471 pre_html => $pre_ul,
472 accesskey => "$nr",
473 tabindex => "$nr",
474 href => "slide$nr.html",
475 title => $title,
476 post_html => $post_ul,
477 more => 0,
478 };
479 push @toc_entries,$item;
480 } else {
481 $item = {
482 pre_html => $pre_ul,
483 tabindex => "$nr",
484 href => "slide$nr.html",
485 title => $title,
486 post_html => $post_ul,
487 };
488 push @toc_entries,$item;
489 }
490 }
491 ##
492 ##############################################################################
493
494 ##############################################################################
495 ## generate the current slide
496
497 sub createSlide
498 {
499
500 # parameters are respectively the slide title, its content,
501 # its number, the next slide title and the previous slide title
502
503 my ($title,$subtitle,$content,$nr,$prev_title,$next_title) = @_;
504
505 if (! $title) {
506 return 1;
507 }
508
509 # work the slide title, the previous and next titles
510 chomp $title;
511 $title =~ s/\r//ig; # remove the windows CR+LF
512 $next_title =~ s/\r//ig;
513 $prev_title =~ s/\r//ig;
514
515 # Remove any tags from the prev & next titles
516 $next_title =~ s/<[^>]+>//g;
517 $prev_title =~ s/<[^>]+>//g;
518 $title =~ s/<[^>]+>//g;
519
520 # Replace double quotes
521 # $title =~ s/"/&#34;/g;
522 $next_title =~ s/"/&#34;/g;
523 $prev_title =~ s/"/&#34;/g;
524
525 # work the slide content
526 $content =~ s/<\/body>//i; # remove if any
527 $content =~ s/<\/html>//i; # remove if any
528
529 $status = sprintf "Slide %2d: %s %s", $nr, $title, $subtitle;
530 $status =~ s/<[^>]+>//g;
531 $status =~ s/[\n\r]+/ /g;
532 print STDERR "$status\n";
533
534 &verify_html($content); # check the html
535 &check_tags($content); # check open and closed tags
536
537 ## write to the slide
538 open(SLIDE, ">slide$nr.html") || die "can't save slide$nr.html: $!";
539 push @pack_additional,"slide$nr.html" if ($pack);
540
541 my $toc_link = "$overview\.html";
542
543 ## initialization of the navigation links
544 my $next_link = "";
545 my $prev_link = "";
546
547 if ($nr>1) {
548 $prev_link = "slide".($nr-1).".html";
549 # } else {
550 # ## add a link back to the toc for the first slide --CMN 19991102
551 # $prev_link = "$overview\.html";
552 }
553
554 if ($nr != $total) {
555 $next_link = "slide".($nr+1).".html";
556 }
557
558 $stylelink = "";
559 # here is the standard style sheet
560 $stylelink .= "<link href=\"$cssStandard\" rel=\"stylesheet\" type=\"text/css\" title=\"Talk\">";
561
562 my $slide_html=make_progress_bar($nr,$total);
563
564 # undefine body if no content is found (so that template can show
565 # only title and sub-title
566 if ($content !~ m/\S/g) {
567 undef $content;
568 }
569
570 %page_data = (
571 doctype => $doctype,
572 talkTitle => $talkTitle,
573 title => $title,
574 subtitle => $subtitle,
575 http_equiv => $http_equiv,
576 stylelink => $stylelink,
577 body => $body,
578
579 logoLink => $logoLink,
580 logoFile => $logoFile,
581 logoAlt => $logoAlt,
582 logoLink2 => $logoLink2,
583 logoFile2 => $logoFile2,
584 logoAlt2 => $logoAlt2,
585
586
587 content_hight => $content_hight,
588 content => $content,
589
590 prev_link => $prev_link,
591 toc_link => $toc_link,
592 next_link => $next_link,
593 prev_title => $prev_title,
594 toc_title => $loc_toc,
595 next_title => $next_title,
596
597 author => $author,
598 authorUrl => $authorUrl,
599 author2 => $author2,
600 author2Url => $author2Url,
601
602 date => $date,
603
604 slide_html => $slide_html,
605
606 template_dir => "$template/",
607 );
608
609 my $page;
610 if ($content) {
611 $page= new Text::FastTemplate key => 'slide';
612 } else {
613 $page= new Text::FastTemplate key => 'title';
614 }
615
616 if ($pack) {
617 $page_data{template_dir}='';
618 print SLIDE extract_files($page->output( \%page_data ));
619 } else {
620 print SLIDE $page->output( \%page_data );
621 }
622
623 close(SLIDE);
624 return 0;
625 }
626
627 ##############################################################################
628 ## generate all the toc of contents needed for each css choosen by the user
629 ## the default toc is not numbered so it can be served by a request to '/'
630 ## (ie it remains Overview.html whereas the other toc are called Overview_#.html)
631
632 sub generateTOC {
633
634 ## read the general toc
635 open(FOO, "<$overview.html");
636 @TOC = <FOO>;
637 close(FOO);
638 $toc = "@TOC";
639
640 ## for each user CSS file
641 ## starting after the default css
642 for ($css=1;$css<$nbCssStandard;$css++) {
643
644 ## create new TOC
645 $newTOC = $toc;
646
647 ## the links on the toc need also to be modified
648 ## to link to the correct slides
649 $newTOC =~ s/<a accesskey=\"(\d)\" tabindex=\"(\d+)\" href=\"slide(\d+)-\d+\.html\">/<a accesskey=\"$1\" tabindex=\"$2\" href=\"slide$3-$css\.html">/ig;
650 $newTOC =~ s/<a tabindex=\"(\d+)\" href=\"slide(\d+)-\d+\.html\">/<a tabindex=\"$1\" href=\"slide$2-$css\.html">/ig;
651
652 ## write to new TOC
653 $outfile = $overview."-".$css.".html";
654 open(OUT, ">$outfile");
655 print OUT $newTOC;
656 close(OUT)
657 }
658
659
660 }
661
662 ##############################################################################
663 # check that the html of the slide
664 # is correct (ALT tags, ...)
665 # This procedure produces only warning
666 sub verify_html {
667
668 if ($_[0] =~ /<img([^>]*)>/im) {
669 if (!($1 =~ /ALT=/im)) {
670 print STDERR "WARNING: <IMG> without ALT\n";
671 print STDERR " <IMG$1>\n" ;
672 }
673 }
674 }
675
676 ##############################################################################
677 # clean the html of the slide
678 # remove all <div class="comment">blabla</div>
679 sub clean_html {
680 my $tmp=$_[0];
681 $tmp =~ s/<div\s+class\s*=\s*(?:comment[\s>]|\"comment\").*?<\/div>//igs;
682 $tmp =~ s,</*font[^>]+>,,ig;
683 return $tmp;
684 }
685
686 ##############################################################################
687 # make transparent 1x1 gif (for layout tricks)
688 sub make_dotgif {
689 @dot_gif=(71,73,70,56,57,97,1,0,1,0,128,0,0,192,192,192,0,0,0,33,
690 249,4,1,0,0,0,0,44,0,0,0,0,1,0,1,0,0,2,2,68,1,0,59);
691 open(GIF,"> $_[0]") || die "can't write gif $_[0]: $!";
692 my $dotgif;
693 foreach (@dot_gif) {
694 $dotgif.=chr($_);
695 }
696 print GIF $dotgif;
697 close(GIF);
698 }
699
700 ##############################################################################
701 # make slide progress bar
702 sub make_progress_bar {
703 my ($nr,$total) = @_;
704
705 my $pcnt_done=int($nr*100/$total);
706 my $pcnt_left=100-$pcnt_done;
707
708 if ($progress_bar && uc($progress_bar) ne "NO") {
709 my $l=$r="&nbsp;";
710 my $t="$nr of $total";
711 if ($pcnt_done > 50) {
712 $l=$t;
713 } else {
714 $r=$t;
715 }
716 $html='<table border="0" width="50%" cellpadding="0" cellspacing="0" align="right"><tr>';
717 if ($pcnt_done != 0) {
718 $html.='<td width="'.$pcnt_done.'%" class="pcnt-done">'.$l.'</td>';
719 }
720 if ($pcnt_left != 0) {
721 $html.='<td width="'.$pcnt_left.'%" class="pcnt-left">'.$r.'</td>';
722 }
723 $html.='</tr></table>';
724 } else {
725 $html="$loc_slide $nr $loc_of $total";
726 }
727
728 return $html;
729 }
730
731 ##############################################################################
732 # remove anchors <a href...> from html (for titles)
733 sub remove_anchor {
734 my $tmp = $_[0];
735 $tmp =~ s/(.*)<A[^>]*>(.*)<\/A>(.*)/$1$2$3/ig;
736 return $tmp;
737 }
738
739 ##############################################################################
740 # extract files referenced in presentation and remove dirs from slide html
741
742 sub extract_files {
743 my $tmp = $slide = $_[0];
744 while ($tmp =~ s/href="*([^"\s]+)"*//ism ||
745 $tmp =~ s/src="*([^"\s]+)"*//ism) {
746 if ("$1" !~ m/[hf]t?tp:/ && -f "$1" && !grep(/$1/,@pack_additional)) {
747 my $file=$1;
748 push @pack_additional,$file;
749 if ($file =~ m,^(.+)/([^/]+),) {
750 my ($d,$f) = ($1,$2);
751 $slide =~ s,${d}/${f},${f},g;
752 }
753 }
754 }
755 return $slide;
756 }
757
758 ##############################################################################
759 # check tags in slide
760 # based on code from hindent 1.1.2 by Paul Balyoz <pab@domtools.com>
761
762 sub init_nesttag {
763 # Tags that require their own end tag <TAG>...</TAG> we will nest them
764 # properly: (WARNING, you must use lower-case here)
765 # All other tags (not on this list) will be ignored for indenting purposes.
766 return (
767 'html' => 1,
768 'head' => 1,
769 'body' => 1,
770 'title' => 1,
771
772 'a' => 1,
773
774 'table' => 1,
775 'tr' => 1,
776 'th' => 1,
777 'td' => 1,
778
779 'form' => 1,
780 'select' => 1,
781 'textarea' => 1,
782
783 # 'p' => 1, Don't do this one because many people use <P> but not </P>
784 'ul' => 1,
785 'ol' => 1,
786 'dl' => 1,
787 'blockquote' => 1,
788 'center' => 1,
789 'div' => 1,
790
791 'font' => 1,
792 'pre' => 1,
793 'tt' => 1,
794 'i' => 1,
795 'b' => 1,
796 'u' => 1,
797 'strike' => 1,
798 'big' => 1,
799 'small' => 1,
800 'sub' => 1,
801 'sup' => 1,
802 'em' => 1,
803 'strong' => 1,
804 'dfn' => 1,
805 'code' => 1,
806 'samp' => 1,
807 'kbd' => 1,
808 'var' => 1,
809 'cite' => 1,
810
811 'h1' => 1,
812 'h2' => 1,
813 'h3' => 1,
814 'h4' => 1,
815 'h5' => 1,
816 'h6' => 1,
817
818 'applet' => 1,
819
820 'map' => 1,
821
822 'frameset' => 1,
823 'noframes' => 1,
824 );
825 }
826
827 sub check_tags {
828 my $tmp = $_[0];
829 my @tagstack;
830 my $level=0;
831
832 while ($tmp =~ /<(.*?)>/gsm) {
833 my $tag=$1; $tag=~s/\s.+//g;
834 # if regular tag, push it on stack; if end-tag, pop it off stack.
835 # but don't do any of this if it's not a special "nesting" tag!
836 if ($tag !~ m,^/,) {
837 if ($nesttag{lc($tag)}) {
838 push @tagstack,$tag;
839 $level++; # remember how much for later
840 }
841 } else {
842 $tag =~ s,^/,,; # convert this end-tag to a begin-tag
843 $tag = lc($tag);
844 if ($nesttag{lc($tag)}) {
845 # throw away tags until we find a match
846 if ($#tagstack > -1) {
847 while ($tag ne lc(pop @tagstack)) {
848 $level--; # we threw away extra tags
849 last if $#tagstack <= 0;
850 }
851 $level--; # we threw away extra tags
852 if ($level < 0) {
853 print STDERR "WARNING: more end than begin tags around </$tag> !\n";
854 }
855 }
856 }
857 }
858 }
859
860 if ($level > 0) {
861 print STDERR "WARNING: level=$level, ", $#tagstack+1," tags left on stack after done parsing! Specifically:\n<",join("> <",@tagstack),">\n";
862 }
863
864 }
865

  ViewVC Help
Powered by ViewVC 1.1.26