$2"; } } elsif (/^\?(.*)/) # question (?) { &flush_quest; &flush_para; &flush_list; &flush_table; &flush_pref; $qcount++; $1 =~ /(\w*)\??(\w*)/; $qkey = $1; $qmod = $2; $qkey =~ tr/a-z/A-Z/; $qmod =~ tr/a-z/A-Z/; if ($info{'LAYOUT'} =~ /feedback/i) { $qmod = ""; } if ($info{'LAYOUT'} =~ /nofeedback/i) { $qmod = "NONE"; } if ($info{'LAYOUT'} =~ /print/i) { $qmod = "NONE"; } if ($info{'QUIZCGI'}) { $qmod = "QUIZ"; } if ($info{'FILE'}) { $rfile = "$info{'FILE'}$html"; } else { $rfile = "$qfile$html"; } $qtxt .= "$dtdinfo\n\n\n$mtxinfo\n\n
\nQuestion $qcount - $temp\n"; } elsif (/^@(.*)/) # answer (@) { &flush_para; $acount++; $temp = "$letters[$acount])"; $atxt[$acount] = "$temp $1"; $x = length($qkey); if ($acount == 1) { $main .= "
\n"; } if ($qmod eq "QUIZ") { if ($x == 1) { $main .= "$1\n"; } else { $main .= "
$1\n"; } $y = index($qkey, $letters[$acount]); if ($y >= 0 && $akey =~ /q$qcount=/) { chop($akey); $akey .= ":a$acount\n"; } elsif ($y >= 0) { $akey .= "q$qcount=a$acount\n"; } elsif ($x > 1 && $akey =~ /q$qcount=/) { chop($akey); $akey .= ":x\n"; } elsif ($x > 1) { $akey .= "q$qcount=x\n"; } } elsif ($qmod eq "") { $main .= "
$temp $1\n"; if (index($qkey, $letters[$acount]) < 0) { if ($x == 1) { $atxt[$acount] .= "
Sorry..."; } else { $atxt[$acount] .= "
Sorry..."; } } else { if ($x == 1) { $atxt[$acount] .= "
Correct!"; } else { $atxt[$acount] .= "
Correct, but there are more..."; } } } else { $main .= "
$temp $1\n"; } } elsif (/^-.*/) # horizontal rule (-) { &flush_list; &flush_table; &flush_pref; $para .= "\n
\n"; } elsif (/^''(.*)/) # pull quote ('') { &flush_para; &flush_list; &flush_table; &flush_pref; $main .= "$1
\n"; } elsif (/^=(.*)/) # preformatted text (=) { &flush_para; &flush_list; &flush_table; $pref[$pcount++] = $1; } else # other stuff { &flush_list; &flush_table; &flush_pref; if($para eq "") { $para = $_; } else { $para .= " $_"; } } } &flush_quest; # flush everything just to be sure &flush_para; &flush_list; &flush_table; &flush_pref; ### fix up page info if (!$info{'MTX'}) { print "WARNING: The format of this file is unknown!\n"; } elsif ($info{'MTX'} < 1.5) { print "WARNING: The format of this file ($info{'MTX'}) is not current!\n"; } if ($info{'FILE'}) { $_[1] =~ s/(.*[:\/\\]).*/$1$info{'FILE'}$html/; } else { $_[1] =~ /.*[:\/\\](.*)$html/; $info{'FILE'} = $1; } if (!$info{'TITLE'}) { $info{'TITLE'} = $info{'FILE'}; } if (!$info{'HEADING'}) { $info{'HEADING'} = $info{'TITLE'}; } if ($info{'HEADING'} =~ /(^!\w*$)/) { $info{'HEADING'} = "$1 $info{'TITLE'}"; } if (!$info{'AUTHOR'}) { $info{'AUTHOR'} = $info{'AUTHURL'}; } if (!$info{'CONTACT'}) { $info{'CONTACT'} = $info{'CONTURL'}; } if (!$info{'VERSION'}) { $info{'VERSION'} = $info{'VERSURL'}; } if ($info{'HOMEURL'} && !$info{'HOME'}) { $info{'HOME'} = "Home Page" } if ($info{'PARENTURL'} && !$info{'PARENT'}) { $info{'PARENT'} = "Parent Page" } if ($info{'INDEXURL'} && !$info{'INDEX'}) { $info{'INDEX'} = "Index Page" } if ($info{'PREVURL'} && !$info{'PREV'}) { $info{'PREV'} = "Previous Page" } if ($info{'NEXTURL'} && !$info{'NEXT'}) { $info{'NEXT'} = "Next Page" } if ($info{'LAYOUT'} eq "print") { $info{'OUTLINE'} = "none"; $info{'COUNTER'} = ""; $info{'HOMEURL'} = ""; $info{'PARENTURL'} = ""; $info{'INDEXURL'} = ""; $info{'PREVURL'} = ""; $info{'NEXTURL'} = ""; } if ($info{'LAYOUT'} eq "slide") { $info{'OUTLINE'} = "slide"; } if ($info{'REFRESH'} && $info{'LAYOUT'} eq "slide") { $info{'REFRESH'} =~ s/^(\d+)$//; } elsif ($info{'REFRESH'}) { $info{'REFRESH'} =~ s/^(\d+)$//; } if ($info{'LOGO'} =~ /(^\$?)(.+)/) { $info{'HEADING'} = "$1!$2"; } if ($info{'QUIZCGI'}) { $info{'STAMP'} = time; $info{'STAMP'} =~ s/\d*(\d\d\d\d$)/$1/; } if ($info{'QUIZLIST'}) { $info{'QUIZLIST'} .= ".lst"; } if ($info{'QUIZTYPE'} && !$info{'LAYOUT'}) { $info{'LAYOUT'} = "results"; } if ($info{'ABSTRACT'}) { $info{'ABSTRACT'} = ""; } if ($info{'KEYWORDS'}) { $info{'KEYWORDS'} = ""; } ### process embedded tags $main = &process_tags($main); ### build navigation buttons if ($info{'HOMEURL'} eq 'none') { $navi .= "$info{'HOME'} | "; } elsif ($info{'HOMEURL'}) { $navi .= "$info{'HOME'} | "; } if ($info{'PARENTURL'} eq 'none') { $navi .= "$info{'PARENT'} | "; } elsif ($info{'PARENTURL'}) { $navi .= "$info{'PARENT'} | "; } if ($info{'INDEXURL'} eq 'none') { $navi .= "$info{'INDEX'} | "; } elsif ($info{'INDEXURL'}) { $navi .= "$info{'INDEX'} | "; } if ($info{'PREVURL'} eq 'none') { $navi .= "$info{'PREV'} | "; } elsif ($info{'PREVURL'}) { $navi .= "$info{'PREV'} | "; } if ($info{'NEXTURL'} eq 'none') { $navi .= "$info{'NEXT'} | "; } elsif ($info{'NEXTURL'}) { $navi .= "$info{'NEXT'} | "; } if ($navi) { chop($navi); chop($navi); chop($navi); $navi .= "\n"; } ### build page header $head = "$dtdinfo\n\n\n$mtxinfo\n\n\n"; if ($info{'REFRESH'} && $info{'LAYOUT'} ne "slide") { $head .= "$info{'REFRESH'}\n"; } if ($info{'ABSTRACT'}) { $head .= "$info{'ABSTRACT'}\n"; } if ($info{'KEYWORDS'}) { $head .= "$info{'KEYWORDS'}\n"; } $head .= "$info{'TITLE'} \n\n\n"; if ($info{'WATERMARK'}) { $head .= "\n"; } elsif ($info{'COLORS'}) { $head .= "\n"; } else { $head .= "\n"; } if ($navi) { $head .= $navi . "
\n"; } if ($info{'HEADING'} =~ /^\$(.*)/) { $info{'HEADING'} = $1; $align = " ALIGN=center"; } else { $align = ""; } $info{'HEADING'} =~ s/^!(\w*) ?(.*)//i; if ($main =~ /!HEAD!/) { $main =~ s/!HEAD!/
$info{'HEADING'}<\/H1>/; } else { $head .= "
\n"; } $tail .= "\n\n"; ### build toc/outline $temp = ""; if ($info{'OUTLINE'} eq "none" || $toc[0] eq "") { $toc = "$info{'HEADING'}
\n"; } if ($info{'QUIZCGI'}) { $head .= "
"; } elsif ($info{'OUTLINE'} eq "slide") { $toc = "
\n\n"; foreach $item (@toc) { $toc .= "
\n- $item\n"; } $toc .= "$temp
\n\n"; $toc .= "A Note on These Slides: To begin, select any slide from "; $toc .= "the list above. Use the controls (< i >) to move forward, backward, or return "; $toc .= "to this index. Increase the font size of your browser for optimal viewing."; if ($x = index($main,"!TOC!")) { $stxt = substr($main,$x+6); $main = substr($main,0,$x+6); } } elsif ($info{'OUTLINE'} eq "long") { $level = 1; foreach $item (@toc) { # print "$level $item\n"; $item =~ s/(.*)\|(.*)/$2/; if ($1 == $level) { $temp .= "$item\n"; } elsif ($1 > $level) { $temp .= " \n$item\n"; } else { while($level > $1) { $level--; $temp .= "
\n"; } $temp .= "$item\n"; } $level = $1; } while ($level > 1) { $level--; $temp .= "\n"; } $toc = "
\n$temp
"; } else { foreach $item (@toc) { $item =~ s/(.*)\|(.*)/$2 \| /; if ($1 == 2){ $temp .= "$item\n"; } } chop($temp); chop($temp); chop($temp); $toc = "
\n$temp\n
"; } if ($main =~ /!TOC!/) { $main =~ s/!TOC!/$toc/; } ### output page open(OUTFILE,">$_[1]") || die "Can't open output file $_[1].\n"; print "writing: $_[1]\n"; print OUTFILE "$head$main$tail"; close(INFILE); close(OUTFILE); defined($mac) and MacPerl::SetFileInfo("MOSS", "TEXT", $_[1]); # netscape mac only ### output slides $scount = 0; $x = index($stxt,"<-1) { $temp = substr($stxt,1,$x); $temp =~ s/ //; chop($temp); $stxt = substr($stxt,$x); $scount++; $prevnum = $scount-1; $nextnum = $scount+1; $file = "$qpath$qfile$scount$html"; $prev = "$qfile$prevnum$html"; $next = "$qfile$nextnum$html"; $refn = "$qfile$nextnum$html"; if ($scount == 1) { $prev = "$info{'FILE'}$html"; } elsif ($scount == $hcount) { $next = "$info{'FILE'}$html"; $refn = $qfile . "1$html"; } # $picon = "prev.gif"; $iicon = "index.gif"; $nicon = "next.gif"; # $temp =~ s/.*
(.*)<\/H.><\/A>/ $info{'TITLE'} - $1<\/TITLE>\n<\/HEAD>\n \n\n<\/A>
<\/A>
<\/A>
$1<\/STRONG><\/CENTER>\n
\n/i; if ($info{'REFRESH'}) { $refresh = "$info{'REFRESH'}$refn\">"; } $controls = "< <\/A>"; $controls .= "i<\/A>"; $controls .= " ><\/A><\/TT>\n"; $body = ""; $temp = "$dtdinfo\n\n\n$mtxinfo\n\n\n$refresh\n" . $temp; $temp =~ s/(.*)<\/A><\/H.>/ $1 - $info{'TITLE'}<\/TITLE>\n<\/HEAD>\n$body\n\n$controls $1<\/STRONG><\/CENTER>\n
/i; $temp .= "\n"; open(OUTFILE,">$file") || die "Can't open output file $file.\n"; print "writing: $file\n"; print OUTFILE $temp; close(OUTFILE); } ### output quiz key if ($info{'QUIZCGI'}) { $file = "$qpath$qfile.key"; open(OUTFILE,">$file") || die "Can't open output file $file.\n"; print "writing: $file\n"; print OUTFILE "$info{'TITLE'}\|$ts\|$info{'STAMP'}\|$info{'LAYOUT'}\|$info{'EXPIRES'}\|$info{'QUIZLIST'}\n$akey"; close(OUTFILE); } } ### add paragraph to main text ### sub flush_para { if ($para ne "") { if ($para =~ /^\$(.*)/) { $main .= "$1\n"; } elsif ($para =~ /^\'(.*)/) { $main .= "
$1\n"; } elsif ($para =~ /^\+(.*)/ && $info{'LAYOUT'} ne "print") { $main .= "$1\n"; } elsif ($para =~ /^\+(.*)/ && $info{'LAYOUT'} eq "print") { ; } # do nothing else { $main .= "
$para\n"; } if ($qtxt ne "") { $qtxt .= "
$para\n"; } $para = ""; } } ### add preformatted text to main ### sub flush_pref { if (@pref) { $main .= "
"; foreach $item (@pref) { $main .= "$item\n"; } $main .= "\n"; } undef @pref; $pcount = 0; } ### add list to main text ### sub flush_list { $level = 0; foreach $item (@list) { $item =~ /(\d) (.)(.*)/; $item = $3; if($2 eq "#") {$stag[$1] = ""; $etag[$1] = "
"; $itag[$1] = ""; } elsif($2 eq "@") {$stag[$1] = " "; $etag[$1] = "
"; $itag[$1] = ""; } elsif($2 eq "!") {$stag[$1] = " "; $etag[$1] = "
"; $itag[$1] = ""; } elsif($2 eq "+") {$stag[$1] = " "; $etag[$1] = "
"; $itag[$1] = ""; $item = "$item"; } elsif($2 eq "-") {$stag[$1] = " "; $etag[$1] = "
"; $itag[$1] = ""; } else {$stag[$1] = " "; $etag[$1] = "
"; $itag[$1] = ""; $item = $2 . $3; } if ($1 > $level) # start list { $level = $1; $main .= "$stag[$1]\n"; } elsif ($1 < $level) # end list { while ($1 < $level) { $main .= "$etag[$level--]\n"; } } $main .= "$itag[$1]$item\n"; # list item } while ($level > 0) { $main .= "$etag[$level--]\n"; } undef @list; $lcount = 0; } ### add table to main text ### sub flush_table { if (@table) { $caption =~ s/^\|([^|]*)(.*)/$1/; $type = $2; $caption =~ s/none//i; if ($type =~ /(nowide\|noborder|noborder\|nowide)/) { $main .= " \n"; } elsif ($type =~ /nowide/) { $main .= "
\n"; } elsif ($type =~ /noborder/) { $main .= "
\n"; } else { $main .= "
\n"; } undef @table; undef $caption; $tcount = 0; } ### output question feedback files ### sub flush_quest { if ($acount > 0) { $main .= "\n"; # ??dead code?? if ($qmod eq "") { $cnt = 0; $qtxt = &process_tags($qtxt); while ($acount > $cnt) { $cnt++; $file = "$qpath$qfile$qcount$letters[$cnt]$html"; open(OUTFILE,">$file") || die "Can't open output file $file.\n"; print "writing: $file\n"; $atxt[$cnt] = &process_tags($atxt[$cnt]); print OUTFILE "$qtxt\n \n"; } if ($caption) { $main .= "
" . $caption . " \n"; } foreach $item (@table) { $main .= ""; while ($item) { $item =~ s/^\|([^|]*)(.*)/$2/; $cell = $1; $cell =~ s/(.*[\S|\*])(\s*$)/$1/; $cell =~ s/(^[\*|^]?)(.*)/$2/; $tag = $1; $cell =~ s/\s*//; if ($cell =~ /(.*)\\(\d*)/) { $cell = $1; $col = " COLSPAN=$2 ALIGN=center>"; } else { $col = ">"; } if ((!$cell) && ($type =~ /noblanks/)) { $tag = "*"; } if (($tag eq "*") && $cell) { $main .= " \n"; } $main .= ""; } elsif ($tag eq "*") { $main .= " " . " " . " "; } elsif ($tag eq "^") { $main .= ""; } else { $main .= " "; } } $main .= " \n\n\n"; close(OUTFILE); } } undef $qtxt; undef $qkey; undef $qmod; undef @atxt; $acount = 0; } } ### process embedded tags ### sub process_tags { $temp = $_[0]; $temp =~ s/{P}/"; print OUTFILE "$atxt[$cnt]\n"; print OUTFILE "
/gi; $temp =~ s/{B}/
/gi; $temp =~ s/{S}/ /gi; $temp =~ s/{C}/
/gi; $temp =~ s/{!//g; $temp =~ s/!}/<\/EM>/g; $temp =~ s/{\*//g; $temp =~ s/\*}/<\/STRONG>/g; $temp =~ s/{@//g; $temp =~ s/@}/<\/TT>/g; # F replaces @ $temp =~ s/{F//g; $temp =~ s/F}/<\/TT>/g; $temp =~ s/{B//g; $temp =~ s/B}/<\/BIG>/g; $temp =~ s/{S//g; $temp =~ s/S}/<\/SMALL>/g; $temp =~ s/{P//g; $temp =~ s/P}/<\/SUP>/g; $temp =~ s/{N//g; $temp =~ s/N}/<\/SUB>/g; $temp =~ s/{#([^{}]*@[^{}]*)##}/$1<\/A>/g; $temp =~ s/{#([^{}]*)##}/$1<\/A>/g; $temp =~ s/{#([^{}]*)#=([^{}]*)#}/$1<\/A>/g; $temp =~ s/{#([^{}]*)#(#[^{}]*)#}/$1<\/A>/g; $temp =~ s/{#([^{}#]*)#([^{}]*@[^{}]*)#}/$1<\/A>/g; $temp =~ s/{#([^{}#]*)#([^{}]*)#}/$1<\/A>/g; $temp =~ s/{=(\w*)=}//gi; $temp =~ s/{=(\w*) (.*)=}/
/gi; $temp =~ s/{=\$(\w*)=}/
/gi; $temp =~ s/{=\$(\w*) (.*)=}/
/gi; $temp =~ s/{=\\(\w*)=}/
/gi; $temp =~ s/{=\\(\w*) (.*)=}/
/gi; $temp =~ s/{=\/(\w*)=}/
/gi; $temp =~ s/{=\/(\w*) (.*)=}/
/gi; $temp =~ s/{\+(\w*)\+}/
<\/A>/gi; $temp =~ s/{\+(\w*) (.*)\+}/
<\/A>/gi; $temp =~ s/{\+\$(\w*)\+}/
<\/A>/gi; $temp =~ s/{\+\$(\w*) (.*)\+}/
<\/A>/gi; $temp =~ s/{\+\\(\w*)\+}/
<\/A>/gi; $temp =~ s/{\+\\(\w*) (.*)\+}/
<\/A>/gi; $temp =~ s/{\+\/(\w*)\+}/
<\/A>/gi; $temp =~ s/{\+\/(\w*) (.*)\+}/
<\/A>/gi; $temp =~ s/{-(\w*)-}/
<\/A>/gi; $temp =~ s/{-(\w*) (.*)-}/
<\/A>/gi; $temp =~ s/{-\$(\w*)-}/
<\/A>/gi; $temp =~ s/{-\$(\w*) (.*)-}/
<\/A>/gi; $temp =~ s/{-\\(\w*)-}/
<\/A>/gi; $temp =~ s/{-\\(\w*) (.*)-}/
<\/A>/gi; $temp =~ s/{-\/(\w*)-}/
<\/A>/gi; $temp =~ s/{-\/(\w*) (.*)-}/
<\/A>/gi; $temp =~ s/{#(\w*)#}/
<\/A>/gi; $temp =~ s/{#(\w*) (.*)#}/
<\/A>/gi; $temp =~ s/{#\$(\w*)#}/
<\/A>/gi; $temp =~ s/{#\$(\w*) (.*)#}/
<\/A>/gi; $temp =~ s/{#\\(\w*)#}/
<\/A>/gi; $temp =~ s/{#\\(\w*) (.*)#}/
<\/A>/gi; $temp =~ s/{#\/(\w*)#}/
<\/A>/gi; $temp =~ s/{#\/(\w*) (.*)#}/
<\/A>/gi; $temp =~ s/{M(\w*)M}/