#!/usr/bin/perl -W use strict; use English; my $outdir = "gen"; my $stub; my $RedUpdate=" Update"; my $PinkUpdate=" Update"; # open the outline file open (OUTLINE,"); close (OUTLINE); my $outline_base=join('',@outline_tmp); # create the output subdir if it doesn't already exist if (! ( -d $outdir )) { mkdir($outdir) || die ("can't make output dir - $!"); } #create a sub-dir the hebrew files if (! ( -d $outdir.'/hebrew' )) { mkdir($outdir.'/hebrew') || die ("can't make output dir - $!"); } # process the files foreach $stub (@ARGV){ open (IN,"<$stub") || die ("can't open $stub - $!"); my @page_tmp=(); close(IN); my $page=join('',@page_tmp); my $html=$stub; ($html=~s/htm$/html/) or $html.='.html'; #get the the first line, which is heading1 (

), and use it for title. #we shave it off for now. #later on, we stick it back inside in the proper place #first we shave the

we expect $page=~s|^\s*\<\s*h1\s*\>||i or die "no heading

for $stub\n"; #then we seek a closing

. we seperate by it the title. # we do not use the following form: # $page=~s|^\s*\<\s*h1\s*\>([^\<]+)\<\s*\/h1\s*\>||i # or die "no heading for $stub\n"; # in order to allow for tags within the title (for links and modifiers- for example,
) $page=~s|\<\s*\/h1\s*\>||i or die "no heading for $stub\n"; my $head=$`; $page=$'; my $site_name = "Haifux - Haifa Linux Club"; my $title = (($head eq $site_name) ? $site_name : "$site_name - $head"); #title cannot have any tags inside it, but we may need tags for redirection $title=~s/\<[^\>]*\>//g; print "$stub, $head\n"; my $outline=$outline_base; my $is_hebrew=($html=~/hebrew\//); my $other_language; my $direct_to_other_language; if ($is_hebrew){ $other_language='../'.$POSTMATCH; $direct_to_other_language="This page in English"; $page="\
$page\<\/div\>"; $head="\
$head\<\/div\>"; }else{ $other_language='hebrew/'.$html; $direct_to_other_language="דף זה בעברית"; } my $link_to_other_language=''. $direct_to_other_language.''; $outline=~s/LinkToThisPageInOtherLanguage/$link_to_other_language/; $outline=~s/InsertTextHere/$page/; $outline=~s/InsertHeadHere/$head/; $outline=~s/InsertTitleHere/$title/; if($is_hebrew) { $outline=~s/>[^<]+/>$1<\/span>/g; } $outline=~s/RedUpdate/$RedUpdate/g; $outline=~s/PinkUpdate/$PinkUpdate/g; #Find examples, and convert them to text by inserting before each \n while ($outline=~/BeginExampleHere/){ my $before=$PREMATCH; my $rest=$POSTMATCH; ($rest=~/EndExampleHere/) or die "example begun but not ended on $stub\n"; my $after=$POSTMATCH; my $example=$PREMATCH; $example=~s/\n/\
\n/g; $outline=$before.$example.$after; } my $outname = "$outdir/$html"; open(OUT,">$outname") || die ("can't open output file $outname - $!"); print OUT $outline; close(OUT); }