--- loncom/xml/londefdef.pm 2002/10/08 20:09:17 1.92 +++ loncom/xml/londefdef.pm 2002/11/09 22:05:33 1.100 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # Tags Default Definition Module # -# $Id: londefdef.pm,v 1.92 2002/10/08 20:09:17 sakharuk Exp $ +# $Id: londefdef.pm,v 1.100 2002/11/09 22:05:33 albertel Exp $ # # # Copyright Michigan State University Board of Trustees @@ -109,28 +109,38 @@ sub end_m { return $currentstring; } #-- tag - sub start_html { - my ($target,$token) = @_; - my $currentstring = ''; - if ($ENV{'browser.mathml'}) { - &tth::ttminit(); - } else { - &tth::tthinit(); - } - if ($target eq 'web') { - $currentstring = &Apache::lonxml::xmlbegin(). - &Apache::lonxml::fontsettings(); - } elsif ($target eq 'tex') { - @Apache::londefdef::table = (); - $currentstring .= '\documentclass[letterpaper]{article} +sub start_html { + my ($target,$token) = @_; + my $currentstring = ''; + if ($ENV{'browser.mathml'}) { + &tth::ttminit(); + if ($ENV{'browser.unicode'}) { + &tth::ttmoptions('-L -u1'); + } else { + &tth::ttmoptions('-L -u0'); + } + } else { + &tth::tthinit(); + if ($ENV{'browser.unicode'}) { + &tth::tthoptions('-L -u1'); + } else { + &tth::tthoptions('-L -u0'); + } + } + if ($target eq 'web') { + $currentstring = &Apache::lonxml::xmlbegin(). + &Apache::lonxml::fontsettings(); + } elsif ($target eq 'tex') { + @Apache::londefdef::table = (); + $currentstring .= '\documentclass[letterpaper]{article} \newcommand{\keephidden}[1]{} \renewcommand{\deg}{$^{\circ}$} \usepackage[dvips]{graphicx} \usepackage{epsfig}\usepackage{calc} \newenvironment{choicelist}{\begin{enumerate}}{\end{enumerate}}'; - } - return $currentstring; - } + } + return $currentstring; +} sub end_html { my ($target,$token) = @_; my $currentstring = ''; @@ -845,7 +855,7 @@ EDITBUTTON $currentstring .= $token->[4]; } elsif ($target eq 'tex') { if ($$tagstack[-2] ne 'sub' && $$tagstack[-2] ne 'sup') { - $currentstring .= '\vskip 0 mm'; + $currentstring .= '\vskip 0.2 mm'; } } elsif ($target eq 'latexsource') { $currentstring .= '\\'; @@ -1412,7 +1422,8 @@ sub start_table { if ($signature) { my $NumberEmptyLength = $how_many_columns - $filled_columns; my $SpacePerColumn = '(\textwidth '.$available_space.')/'.$NumberEmptyLength; - $output =~ s/\$SpacePerColumn/$SpacePerColumn/g; + my $shorthand = ($NumberEmptyLength+1)*4; + $output =~ s/\$SpacePerColumn/$SpacePerColumn - $shorthand mm/g; } $Apache::londefdef::table[-1]{'output'} .= $header_of_table.$output.$Apache::londefdef::table[-1]{'hinc'}.'\end{tabular}\vskip 0 mm '; if ($#Apache::londefdef::table > 0) { @@ -1542,17 +1553,18 @@ sub start_table { #-- tag sub start_img { my ($target,$token,$tagstack,$parstack,$parser,$safeeval) = @_; - $Apache::lonxml::extlinks[$#Apache::lonxml::extlinks+1]= - $token->[2]->{'src'}; + my $src = &Apache::lonxml::get_param('src',$parstack,$safeeval, + undef,1); + $Apache::lonxml::extlinks[$#Apache::lonxml::extlinks+1]=$src; my $currentstring = ''; my $width_param = ''; my $height_param = ''; my $scaling = .3; if ($target eq 'web') { - $currentstring = $token->[4]; + $currentstring = $token->[4]; } elsif ($target eq 'tex') { - my $src = &Apache::lonxml::get_param('src',$parstack,$safeeval); + &image_replication($src); $src=&Apache::lonnet::filelocation($Apache::lonxml::pwd[-1],$src); #if original gif/jpg file exist do following: if (-e $src) { @@ -1590,7 +1602,7 @@ sub start_table { if (-e $newsrc) { #eps counterpart for image exist if ($path) { - $currentstring .= '\noindent\graphicspath{{'.$path.'}}\fbox{\includegraphics[width='.$width_param.' mm]{'.$file.'}} '; + $currentstring .= '\vskip 1 mm \noindent\graphicspath{{'.$path.'}}\fbox{\includegraphics[width='.$width_param.' mm]{'.$file.'}} '; } } else { #there is no eps counterpart for image - check for ps one @@ -1599,7 +1611,7 @@ sub start_table { #ps counterpart for image exist $file =~ s/\.eps$/\.ps/; if ($path) { - $currentstring .= '\noindent\graphicspath{{'.$path.'}}\fbox{\includegraphics[width='.$width_param.' mm]{'.$file.'}} '; + $currentstring .= '\vskip 1 mm \noindent\graphicspath{{'.$path.'}}\fbox{\includegraphics[width='.$width_param.' mm]{'.$file.'}} '; } } else { #there aren't eps or ps - so create eps @@ -1607,7 +1619,7 @@ sub start_table { my $filename = "/home/httpd/prtspool/$ENV{'user.name'}_$ENV{'user.domain'}_printout.dat"; $temp_file = Apache::File->new('>>'.$filename); print $temp_file "$src\n"; - $currentstring .= '\graphicspath{{/home/httpd/prtspool/}}\fbox{\includegraphics[width='.$width_param.' mm]{'.$file.'}} '; + $currentstring .= '\vskip 1 mm \graphicspath{{/home/httpd/prtspool/}}\fbox{\includegraphics[width='.$width_param.' mm]{'.$file.'}} '; } } } else { @@ -1713,27 +1725,30 @@ sub start_embed { return $currentstring; } #-- tag - sub start_allow { - my ($target,$token,$tagstack,$parstack,$parser,$safeeval) = @_; - $Apache::lonxml::extlinks[$#Apache::lonxml::extlinks+1]= - $token->[2]->{'src'}; - my $src = &Apache::lonxml::get_param('src',$parstack,$safeeval); - if (not -e '/home/httpd/html'.$src) { - #replicates image itself - &Apache::lonnet::repcopy('/home/httpd/html'.$src); - #replicates eps or ps - my $newsrc = $src; - $newsrc =~ s/(.gif|.jpg)$/.eps/; - if (not-e $newsrc && &Apache::lonnet::repcopy('/home/httpd/html'.$newsrc) ne 'OK') { - $newsrc =~ s/\.ps$/\.eps/; - &Apache::lonnet::repcopy('/home/httpd/html'.$newsrc); - } - } - return ''; - } - sub end_allow { - return ''; - } +sub start_allow { + my ($target,$token,$tagstack,$parstack,$parser,$safeeval) = @_; + $Apache::lonxml::extlinks[$#Apache::lonxml::extlinks+1]= + $token->[2]->{'src'}; + my $src = &Apache::lonxml::get_param('src',$parstack,$safeeval); + &image_replication($src); + my $result; + if ($target eq 'edit') { + $result .=&Apache::edit::tag_start($target,$token); + $result .=&Apache::edit::text_arg('File Spec:','src',$token,70); + $result .=&Apache::edit::end_row();#.&Apache::edit::start_spanning_row(); + } elsif ($target eq 'modified') { + my $constructtag=&Apache::edit::get_new_args($token,$parstack, + $safeeval,'src'); + if ($constructtag) { $result = &Apache::edit::rebuild_tag($token); } + } + return $result; +} + +sub end_allow { + my ($target,$token,$tagstack,$parstack,$parser,$safeeval) = @_; + if ( $target eq 'edit') { return (&Apache::edit::end_table()); } + return ''; +} #-- Frames sub start_frameset { my ($target,$token) = @_; @@ -2527,5 +2542,22 @@ sub start_embed { } return $currentstring; } + +sub image_replication { + my $src = shift; + if (not -e '/home/httpd/html'.$src) { + #replicates image itself + &Apache::lonnet::repcopy('/home/httpd/html'.$src); + #replicates eps or ps + my $newsrc = $src; + $newsrc =~ s/(.gif|.jpg)$/.eps/; + if (not-e $newsrc && &Apache::lonnet::repcopy('/home/httpd/html'.$newsrc) ne 'OK') { + $newsrc =~ s/\.ps$/\.eps/; + &Apache::lonnet::repcopy('/home/httpd/html'.$newsrc); + } + } + return ''; +} + 1; __END__