1 |
#!/usr/bin/perl |
#!/usr/bin/perl |
2 |
# |
# |
3 |
# SLies Copyright 2001 Dobrica Pavlinusic <dpavlin@rot13.org> |
# PLies Copyright 2001 Dobrica Pavlinusic <dpavlin@rot13.org> |
4 |
# |
# |
5 |
# this tool is based on SlideMaker and XLSies tool |
# this tool is based on SlideMaker and XLSies tool |
6 |
# split a all.htm into slide*.htm |
# split a all.htm into slide*.htm |
240 |
|
|
241 |
## step 1: record anchors |
## step 1: record anchors |
242 |
for($i=0; $i<$total; $i++) { |
for($i=0; $i<$total; $i++) { |
243 |
my $tmp = $table[($i*2)]; |
my $tmp = $table[($i*2)].$table[($i*2)+1]; |
244 |
while ($tmp =~ s,<a +name="*([^>"]+)"*>,,i) { |
while ($tmp =~ s,<a +name="*([^>"]+)"*>,,i) { |
245 |
$anchor_on_slide{$1}=($i+1); |
$anchor_on_slide{$1}=($i+1); |
246 |
print "\tslide ",($i+1)," anchor: $1\n" if ($debug); |
print "\tslide ",($i+1)," anchor: $1\n" if ($debug); |
278 |
## need to check if the title contains any anchor |
## need to check if the title contains any anchor |
279 |
## if so it needs to be removed |
## if so it needs to be removed |
280 |
## because the title is being used in the table of content to link to the corresponding slide |
## because the title is being used in the table of content to link to the corresponding slide |
281 |
$table[0] =~ s/(.*)<A[^>]*>(.*)<\/A>(.*)/$1$2$3/i; |
$table[0] = remove_anchor($table[0]); |
282 |
|
|
283 |
## grab next slide title $table[2] (if there's a next slide) |
## grab next slide title $table[2] (if there's a next slide) |
284 |
## to be able to use in the 'next' navigation button |
## to be able to use in the 'next' navigation button |
285 |
## keep in mind that $table[1] contains the slide corresponding to the title $table[0] |
## keep in mind that $table[1] contains the slide corresponding to the title $table[0] |
286 |
if ($table[2]) { |
if ($table[2]) { |
287 |
$next_title= $table[2]; |
$next_title= remove_anchor($table[2]); |
|
## remove any anchor from the next slide title |
|
|
$next_title =~ s/(.*)<A[^>]*>(.*)<\/A>(.*)/$1$2$3/i; |
|
288 |
} |
} |
289 |
|
|
290 |
## the current slide content is stored $table[1] |
## the current slide content is stored $table[1] |
295 |
|
|
296 |
## extract slide Sub Title <h2> |
## extract slide Sub Title <h2> |
297 |
undef $slideSubTitle; |
undef $slideSubTitle; |
298 |
if ($slideContent =~ s/<[hH]2[^>]*>([^<]+)<\/[hH]2[^>]*>//) { |
if ($slideContent =~ s/<[hH]2[^>]*>(.+)<\/[hH]2[^>]*>//sm) { |
299 |
$slideSubTitle=$1; |
$slideSubTitle=remove_anchor($1); |
300 |
} |
} |
301 |
|
|
302 |
## add the title of the current slide to the table of content |
## add the title of the current slide to the table of content |
308 |
&createSlide($slideTitle,$slideSubTitle,$slideContent ,$slideCount++,$prev_title,$next_title); |
&createSlide($slideTitle,$slideSubTitle,$slideContent ,$slideCount++,$prev_title,$next_title); |
309 |
|
|
310 |
## save the title of the previous slide to be displayed in the 'previous' navigation button |
## save the title of the previous slide to be displayed in the 'previous' navigation button |
311 |
$prev_title="$table[0]"; |
$prev_title=remove_anchor($table[0]); |
312 |
} |
} |
313 |
## process the next slide |
## process the next slide |
314 |
while (shift(@table)); |
while (shift(@table)); |
412 |
if ($nr % $toc_on_page == 0) { |
if ($nr % $toc_on_page == 0) { |
413 |
my $toc_nr=int($nr/$toc_on_page); |
my $toc_nr=int($nr/$toc_on_page); |
414 |
|
|
415 |
%item = ( |
$item = { |
416 |
pre_html => $pre_ul, |
pre_html => $pre_ul, |
417 |
accesskey => " ", # space |
accesskey => " ", # space |
418 |
href => "index-toc$toc_nr.html", |
href => "index-toc$toc_nr.html", |
419 |
title => "...", |
title => "...", |
420 |
post_html => $post_ul, |
post_html => $post_ul, |
421 |
more => 1, # use style for more pages link (...) |
more => 1, # use style for more pages link (...) |
422 |
) |
}; |
423 |
# push @toc_entries, %item; |
push @toc_entries, $item; |
424 |
|
|
425 |
&closeOverview; |
&closeOverview; |
426 |
|
undef @toc_entries; |
427 |
&openOverview("$overview-toc$toc_nr"); |
&openOverview("$overview-toc$toc_nr"); |
428 |
$last_toc_title=''; |
$last_toc_title=''; |
429 |
} |
} |
451 |
}; |
}; |
452 |
push @toc_entries,$item; |
push @toc_entries,$item; |
453 |
} else { |
} else { |
454 |
%item = ( |
$item = { |
455 |
pre_html => $pre_ul, |
pre_html => $pre_ul, |
456 |
tabindex => "$nr", |
tabindex => "$nr", |
457 |
href => "slide$nr.html", |
href => "slide$nr.html", |
458 |
title => $title, |
title => $title, |
459 |
post_html => $post_ul, |
post_html => $post_ul, |
460 |
) |
}; |
461 |
# push @toc_entries,\%item; |
push @toc_entries,$item; |
462 |
} |
} |
463 |
} |
} |
464 |
## |
## |
628 |
# clean the html of the slide |
# clean the html of the slide |
629 |
# remove all <div class="comment">blabla</div> |
# remove all <div class="comment">blabla</div> |
630 |
sub clean_html { |
sub clean_html { |
631 |
$_[0] =~ s/<div\s+class\s*=\s*(?:comment[\s>]|\"comment\").*?<\/div>//igs; |
my $tmp=$_[0]; |
632 |
return $_[0]; |
$tmp =~ s/<div\s+class\s*=\s*(?:comment[\s>]|\"comment\").*?<\/div>//igs; |
633 |
|
$tmp =~ s,</*font[^>]+>,,ig; |
634 |
|
return $tmp; |
635 |
} |
} |
636 |
|
|
637 |
############################################################################## |
############################################################################## |
672 |
return $html; |
return $html; |
673 |
} |
} |
674 |
|
|
675 |
|
############################################################################## |
676 |
|
# make slide progress bar |
677 |
|
sub remove_anchor { |
678 |
|
my $tmp = $_[0]; |
679 |
|
$tmp =~ s/(.*)<A[^>]*>(.*)<\/A>(.*)/$1$2$3/ig; |
680 |
|
return $tmp; |
681 |
|
} |