--- loncom/xml/londefdef.pm 2003/06/30 14:09:03 1.147 +++ loncom/xml/londefdef.pm 2003/08/30 02:41:26 1.158.4.4 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # Tags Default Definition Module # -# $Id: londefdef.pm,v 1.147 2003/06/30 14:09:03 sakharuk Exp $ +# $Id: londefdef.pm,v 1.158.4.4 2003/08/30 02:41:26 albertel Exp $ # # # Copyright Michigan State University Board of Trustees @@ -25,8 +25,7 @@ # /home/httpd/html/adm/gpl.txt # # http://www.lon-capa.org/ -# -# Copyright for TtHfunc and TtMfunc by Ian Hutchinson. +## Copyright for TtHfunc and TtMfunc by Ian Hutchinson. # TtHfunc and TtMfunc (the "Code") may be compiled and linked into # binary executable programs or libraries distributed by the # Michigan State University (the "Licensee"), but any binaries so @@ -157,10 +156,11 @@ sub start_html { &Apache::lonxml::fontsettings(); } elsif ($target eq 'tex') { @Apache::londefdef::table = (); - $currentstring .= '\documentclass[letterpaper]{article}'. - #'\batchmode'. - '\newcommand{\keephidden}[1]{} + $currentstring .= '\documentclass[letterpaper]{article}'; + if ($ENV{'form.latex_type'}=~'batchmode') {$currentstring .='\batchmode';} + $currentstring .= '\newcommand{\keephidden}[1]{} \renewcommand{\deg}{$^{\circ}$} + \usepackage{longtable} \usepackage{textcomp} \usepackage[dvips]{graphicx} \usepackage{epsfig}\usepackage{calc} @@ -363,20 +363,38 @@ sub start_meta { $name=~s/\s/\_/gs; $name=~s/\W//gs; if ($name) { - $currentstring='<'.$name.'>'. + $currentstring='<'.$name; + my $display=&Apache::lonxml::get_param + ('display',$parstack,$safeeval,undef,1); + if ($display) { + $display=~s/\"/\'/g; + $currentstring.=' display="'.$display.'"'; + } + $currentstring.='>'. &Apache::lonxml::get_param ('content',$parstack,$safeeval,undef,1). ''.$name.'>'; } + my $display=&Apache::lonxml::get_param + ('display',$parstack,$safeeval,undef,1); + if ($display) { + $display=&HTML::Entities::encode($display); + $currentstring.='<'.$name.'.display>'.$display. + ''.$name.'.display>'; + } } } elsif ($target eq 'tex') { - &Apache::lonxml::startredirection(); + my $content=&Apache::lonxml::get_param('content',$parstack,$safeeval); + my $name=&Apache::lonxml::get_param('name',$parstack,$safeeval); + if ((not defined $content) && (not defined $name)) { + &Apache::lonxml::startredirection(); + } } return $currentstring; } sub end_meta { - my ($target,$token,$tagstack,$parstack,$parser) = @_; + my ($target,$token,$tagstack,$parstack,$parser,$safeeval) = @_; my $currentstring = ''; if ($target eq 'web') { my $args=''; @@ -385,8 +403,11 @@ sub end_meta { $currentstring = $token->[4]; } } elsif ($target eq 'tex') { - $currentstring=&Apache::lonxml::endredirection(); - $currentstring=''; + my $content=&Apache::lonxml::get_param('content',$parstack,$safeeval); + my $name=&Apache::lonxml::get_param('name',$parstack,$safeeval); + if ((not defined $content) && (not defined $name)) { + &Apache::lonxml::endredirection(); + } } return $currentstring; } @@ -441,10 +462,37 @@ sub start_body { my ($target,$token,$tagstack,$parstack,$parser,$safeeval) = @_; my $currentstring = ''; if ($target eq 'web') { + if ($Apache::lonhomework::parsing_a_problem) { + &Apache::lonxml::warning("
tag found inside of tag
sub start_p {
- my ($target,$token) = @_;
+ my ($target,$token,$tagstack,$parstack,$parser,$safeeval) = @_;
my $currentstring = '';
if ($target eq 'web') {
$currentstring .= $token->[4];
} elsif ($target eq 'tex') {
- $currentstring .= '\par ';
+ my $signal=1;
+ foreach my $tag (@$tagstack) {if (lc($tag) eq 'b') {$signal=0;}}
+ if ($signal) {$currentstring .= '\par ';}
}
return $currentstring;
}
@@ -1064,7 +1114,7 @@ sub start_br {
$currentstring .= $token->[4];
} elsif ($target eq 'tex') {
if ($$tagstack[-2] ne 'sub' && $$tagstack[-2] ne 'sup') {
- $currentstring .= '\vskip 0.2 mm';
+ $currentstring .= '\vskip 0.2 mm ';
}
}
return $currentstring;
@@ -1160,7 +1210,12 @@ sub start_font {
my $currentstring = '';
if ($target eq 'web') {
my $face=&Apache::lonxml::get_param('face',$parstack,$safeeval);
- if ($face=~/symbol/i) {$Apache::lonxml::prevent_entity_encode++;}
+ if ($face=~/symbol/i) {
+ $Apache::lonxml::prevent_entity_encode++;
+ } else {
+ if (($ENV{'browser.fontenhance'} eq 'on') ||
+ ($ENV{'browser.blackwhite'} eq 'on')) { return ''; }
+ }
$currentstring = $token->[4];
} elsif ($target eq 'tex') {
my $fontsize=&Apache::lonxml::get_param('TeXsize',$parstack,$safeeval);
@@ -1292,14 +1347,14 @@ sub start_hr {
if ($target eq 'web') {
$currentstring .= $token->[4];
} elsif ($target eq 'tex') {
- my $LaTeXwidth = &Apache::lonxml::get_param('TeXwidth',$parstack,$safeeval,0);
+ my $LaTeXwidth = &Apache::lonxml::get_param('TeXwidth',$parstack,$safeeval,undef,0);
if (defined $LaTeXwidth) {
if ($LaTeXwidth=~/^%/) {
substr($LaTeXwidth,0,1)='';
$LaTeXwidth=($LaTeXwidth/100).'\textwidth';
}
} else {
- $LaTeXwidth ='0.95\textwidth';
+ $LaTeXwidth ='0.9\textwidth';
}
my ($pre,$post);
my $align=&Apache::lonxml::get_param('align',$parstack,$safeeval,undef,1);
@@ -1310,7 +1365,7 @@ sub start_hr {
} elsif ($align eq 'right') {
$pre=' \hfill \llap{'; $post='}';
}
- $currentstring .= ' \vskip 0 mm \noindent\makebox[\textwidth]{'.$pre.'\makebox['.
+ $currentstring .= ' \vskip 0 mm \noindent\makebox['.$LaTeXwidth.']{'.$pre.'\makebox['.
$LaTeXwidth.'][b]{\hrulefill}'.$post.'}\vskip 0 mm ';
}
return $currentstring;
@@ -1321,8 +1376,7 @@ sub end_hr {
my $currentstring = '';
if ($target eq 'web') {
$currentstring .= $token->[2];
- } elsif ($target eq 'tex') {
- }
+ }
return $currentstring;
}
@@ -1347,30 +1401,30 @@ sub end_div {
#-- tag
sub start_a {
- my ($target,$token) = @_;
+ my ($target,$token,$tagstack,$parstack,$parser,$safeeval) = @_;
my $currentstring = '';
if ($target eq 'web') {
$currentstring .= $token->[4];
} elsif ($target eq 'tex') {
+ my $a=&Apache::lonxml::get_param('href',$parstack,$safeeval,undef,1);
+ $a=~s/([^\\])%/$1\\\%/g;
+ $currentstring .= '\ref{'.$a.'}';
}
return $currentstring;
}
sub end_a {
- my ($target,$token,$tagstack,$parstack,$safeeval) = @_;
+ my ($target,$token,$tagstack,$parstack,$parser,$safeeval) = @_;
my $currentstring = '';
if ($target eq 'web') {
$currentstring .= $token->[2];
- } elsif ($target eq 'tex') {
- my $href=&Apache::lonxml::get_param('href',$parstack,$safeeval,undef,1);
- $currentstring .= '\ref{'.$href.'}';
}
return $currentstring;
}
#--