/[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

Diff of /burst.pl

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.18 by dpavlin, Fri May 11 23:46:40 2001 UTC revision 1.21 by dpavlin, Tue Sep 18 12:50:15 2001 UTC
# Line 135  my %overview_data; Line 135  my %overview_data;
135    
136  my $pack = 0;  my $pack = 0;
137  my @pack_additional;    # additional files to pack (pictures, logos...)  my @pack_additional;    # additional files to pack (pictures, logos...)
138    my %nesttag = init_nesttag();
139    
140  ##############################################################################  ##############################################################################
141  ## reading user input from $infos  ## reading user input from $infos
# Line 427  sub addTitle Line 428  sub addTitle
428          my ($title,$subtitle,$nr) = @_;          my ($title,$subtitle,$nr) = @_;
429          $title =~ s/\r//ig;      # remove the windows CR+LF          $title =~ s/\r//ig;      # remove the windows CR+LF
430          $title =~ s/<[^>]+>//g;          $title =~ s/<[^>]+>//g;
431            $subtitle =~ s/<[^>]+>//g;
432    
433          if (! $title) {          if (! $title) {
434                  return 1;                  return 1;
# Line 524  sub createSlide Line 526  sub createSlide
526          $content =~ s/<\/body>//i; # remove if any          $content =~ s/<\/body>//i; # remove if any
527          $content =~ s/<\/html>//i; # remove if any          $content =~ s/<\/html>//i; # remove if any
528    
529          $status = sprintf "Slide %2d: %s %s\n", $nr, $title, $subtitle;          $status = sprintf "Slide %2d: %s %s", $nr, $title, $subtitle;
530          $status =~ s/<[^>]+>//g;          $status =~ s/<[^>]+>//g;
531          print STDERR $status;          $status =~ s/[\n\r]+/ /g;
532            print STDERR "$status\n";
533    
534          &verify_html($content);    # check the html          &verify_html($content);         # check the html
535            &check_tags($content);          # check open and closed tags
536    
537          ## write to the slide          ## write to the slide
538          open(SLIDE, ">slide$nr.html") || die "can't save slide$nr.html: $!";          open(SLIDE, ">slide$nr.html") || die "can't save slide$nr.html: $!";
# Line 608  sub createSlide Line 612  sub createSlide
612          } else {          } else {
613                  $page= new Text::FastTemplate key => 'title';                  $page= new Text::FastTemplate key => 'title';
614          }          }
615          $page_data{template_dir}='' if ($pack);  
616          print SLIDE $page->output( \%page_data );          if ($pack) {
617          extract_files($page->output( \%page_data )) if ($pack);                  $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);          close(SLIDE);
624          return 0;          return 0;
625  }  }
# Line 728  sub remove_anchor { Line 737  sub remove_anchor {
737  }  }
738    
739  ##############################################################################  ##############################################################################
740  # extract files referenced in presentation  # extract files referenced in presentation and remove dirs from slide html
741    
742  sub extract_files {  sub extract_files {
743          my $tmp = $_[0];          my $tmp = $slide = $_[0];
744          while ($tmp =~ s/href="*([^"\s]+)"*//ism ||          while ($tmp =~ s/href="*([^"\s]+)"*//ism ||
745                  $tmp =~ s/src="*([^"\s]+)"*//ism) {                  $tmp =~ s/src="*([^"\s]+)"*//ism) {
746                  if ("$1" !~ m/[hf]t?tp:/ && -f "$1" && !grep(/$1/,@pack_additional)) {                  if ("$1" !~ m/[hf]t?tp:/ && -f "$1" && !grep(/$1/,@pack_additional)) {
747                          push @pack_additional,$1;                          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    

Legend:
Removed from v.1.18  
changed lines
  Added in v.1.21

  ViewVC Help
Powered by ViewVC 1.1.26