version 1.148, 2003/06/30 15:05:54
|
version 1.158.4.5, 2003/09/02 14:30:31
|
Line 25
|
Line 25
|
# /home/httpd/html/adm/gpl.txt |
# /home/httpd/html/adm/gpl.txt |
# |
# |
# http://www.lon-capa.org/ |
# 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 |
# TtHfunc and TtMfunc (the "Code") may be compiled and linked into |
# binary executable programs or libraries distributed by the |
# binary executable programs or libraries distributed by the |
# Michigan State University (the "Licensee"), but any binaries so |
# Michigan State University (the "Licensee"), but any binaries so |
Line 157 sub start_html {
|
Line 156 sub start_html {
|
&Apache::lonxml::fontsettings(); |
&Apache::lonxml::fontsettings(); |
} elsif ($target eq 'tex') { |
} elsif ($target eq 'tex') { |
@Apache::londefdef::table = (); |
@Apache::londefdef::table = (); |
$currentstring .= '\documentclass[letterpaper]{article}'. |
$currentstring .= '\documentclass[letterpaper]{article}'; |
#'\batchmode'. |
if ($ENV{'form.latex_type'}=~'batchmode') {$currentstring .='\batchmode';} |
'\newcommand{\keephidden}[1]{} |
$currentstring .= '\newcommand{\keephidden}[1]{} |
\renewcommand{\deg}{$^{\circ}$} |
\renewcommand{\deg}{$^{\circ}$} |
|
\usepackage{longtable} |
\usepackage{textcomp} |
\usepackage{textcomp} |
\usepackage[dvips]{graphicx} |
\usepackage[dvips]{graphicx} |
\usepackage{epsfig}\usepackage{calc} |
\usepackage{epsfig}\usepackage{calc} |
Line 319 sub start_title {
|
Line 319 sub start_title {
|
if ($target eq 'web') { |
if ($target eq 'web') { |
$currentstring = $token->[4]; |
$currentstring = $token->[4]; |
} elsif ($target eq 'tex') { |
} elsif ($target eq 'tex') { |
$currentstring .= '\keephidden{' |
$currentstring .= '\keephidden{Title of the document: ' |
} |
} |
if ($target eq 'meta') { |
if ($target eq 'meta') { |
$currentstring='<title>'; |
$currentstring='<title>'; |
Line 363 sub start_meta {
|
Line 363 sub start_meta {
|
$name=~s/\s/\_/gs; |
$name=~s/\s/\_/gs; |
$name=~s/\W//gs; |
$name=~s/\W//gs; |
if ($name) { |
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 |
&Apache::lonxml::get_param |
('content',$parstack,$safeeval,undef,1). |
('content',$parstack,$safeeval,undef,1). |
'</'.$name.'>'; |
'</'.$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') { |
} 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; |
return $currentstring; |
} |
} |
|
|
sub end_meta { |
sub end_meta { |
my ($target,$token,$tagstack,$parstack,$parser) = @_; |
my ($target,$token,$tagstack,$parstack,$parser,$safeeval) = @_; |
my $currentstring = ''; |
my $currentstring = ''; |
if ($target eq 'web') { |
if ($target eq 'web') { |
my $args=''; |
my $args=''; |
Line 385 sub end_meta {
|
Line 403 sub end_meta {
|
$currentstring = $token->[4]; |
$currentstring = $token->[4]; |
} |
} |
} elsif ($target eq 'tex') { |
} elsif ($target eq 'tex') { |
$currentstring=&Apache::lonxml::endredirection(); |
my $content=&Apache::lonxml::get_param('content',$parstack,$safeeval); |
$currentstring=''; |
my $name=&Apache::lonxml::get_param('name',$parstack,$safeeval); |
|
if ((not defined $content) && (not defined $name)) { |
|
&Apache::lonxml::endredirection(); |
|
} |
} |
} |
return $currentstring; |
return $currentstring; |
} |
} |
Line 441 sub start_body {
|
Line 462 sub start_body {
|
my ($target,$token,$tagstack,$parstack,$parser,$safeeval) = @_; |
my ($target,$token,$tagstack,$parstack,$parser,$safeeval) = @_; |
my $currentstring = ''; |
my $currentstring = ''; |
if ($target eq 'web') { |
if ($target eq 'web') { |
|
if ($Apache::lonhomework::parsing_a_problem) { |
|
&Apache::lonxml::warning("<body> tag found inside of <problem> tag this can cause problems."); |
|
return ''; |
|
} |
if (!$Apache::lonxml::registered) { |
if (!$Apache::lonxml::registered) { |
$currentstring.='<head>'. |
$currentstring.='<head>'. |
&Apache::lonmenu::registerurl(undef,$target).'</head>'; |
&Apache::lonmenu::registerurl(undef,$target).'</head>'; |
} |
} |
|
# Accessibility |
|
if ($ENV{'browser.imagesuppress'} eq 'on') { |
|
delete($token->[2]->{'background'}); |
|
} |
|
if ($ENV{'browser.fontenhance'} eq 'on') { |
|
my $style=''; |
|
foreach my $key (keys(%{$token->[2]})) { |
|
if ($key =~ /^style$/i) { |
|
$style.=$token->[2]->{$key}.';'; |
|
delete($token->[2]->{$key}); |
|
} |
|
} |
|
$token->[2]->{'style'}=$style.'; font-size: x-large;'; |
|
} |
|
if ($ENV{'browser.blackwhite'} eq 'on') { |
|
delete($token->[2]->{'font'}); |
|
delete($token->[2]->{'link'}); |
|
delete($token->[2]->{'alink'}); |
|
delete($token->[2]->{'vlink'}); |
|
delete($token->[2]->{'bgcolor'}); |
|
delete($token->[2]->{'background'}); |
|
} |
|
# Overload loads |
my $onLoad=''; |
my $onLoad=''; |
foreach my $key (keys(%{$token->[2]})) { |
foreach my $key (keys(%{$token->[2]})) { |
if ($key =~ /^onload$/i) { |
if ($key =~ /^onload$/i) { |
Line 1037 sub end_q {
|
Line 1085 sub end_q {
|
|
|
#-- <p> tag |
#-- <p> tag |
sub start_p { |
sub start_p { |
my ($target,$token) = @_; |
my ($target,$token,$tagstack,$parstack,$parser,$safeeval) = @_; |
my $currentstring = ''; |
my $currentstring = ''; |
if ($target eq 'web') { |
if ($target eq 'web') { |
$currentstring .= $token->[4]; |
$currentstring .= $token->[4]; |
} elsif ($target eq 'tex') { |
} 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; |
return $currentstring; |
} |
} |
Line 1160 sub start_font {
|
Line 1210 sub start_font {
|
my $currentstring = ''; |
my $currentstring = ''; |
if ($target eq 'web') { |
if ($target eq 'web') { |
my $face=&Apache::lonxml::get_param('face',$parstack,$safeeval); |
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]; |
$currentstring = $token->[4]; |
} elsif ($target eq 'tex') { |
} elsif ($target eq 'tex') { |
my $fontsize=&Apache::lonxml::get_param('TeXsize',$parstack,$safeeval); |
my $fontsize=&Apache::lonxml::get_param('TeXsize',$parstack,$safeeval); |
Line 1292 sub start_hr {
|
Line 1347 sub start_hr {
|
if ($target eq 'web') { |
if ($target eq 'web') { |
$currentstring .= $token->[4]; |
$currentstring .= $token->[4]; |
} elsif ($target eq 'tex') { |
} 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 (defined $LaTeXwidth) { |
if ($LaTeXwidth=~/^%/) { |
if ($LaTeXwidth=~/^%/) { |
substr($LaTeXwidth,0,1)=''; |
substr($LaTeXwidth,0,1)=''; |
Line 1346 sub end_div {
|
Line 1401 sub end_div {
|
|
|
#-- <a> tag |
#-- <a> tag |
sub start_a { |
sub start_a { |
my ($target,$token) = @_; |
my ($target,$token,$tagstack,$parstack,$parser,$safeeval) = @_; |
my $currentstring = ''; |
my $currentstring = ''; |
if ($target eq 'web') { |
if ($target eq 'web') { |
$currentstring .= $token->[4]; |
$currentstring .= $token->[4]; |
} elsif ($target eq 'tex') { |
} elsif ($target eq 'tex') { |
|
my $a=&Apache::lonxml::get_param('href',$parstack,$safeeval,undef,1); |
|
$a=~s/([^\\])%/$1\\\%/g; |
|
$currentstring .= '\ref{'.$a.'}'; |
} |
} |
return $currentstring; |
return $currentstring; |
} |
} |
|
|
sub end_a { |
sub end_a { |
my ($target,$token,$tagstack,$parstack,$safeeval) = @_; |
my ($target,$token,$tagstack,$parstack,$parser,$safeeval) = @_; |
my $currentstring = ''; |
my $currentstring = ''; |
if ($target eq 'web') { |
if ($target eq 'web') { |
$currentstring .= $token->[2]; |
$currentstring .= $token->[2]; |
} elsif ($target eq 'tex') { |
|
my $href=&Apache::lonxml::get_param('href',$parstack,$safeeval,undef,1); |
|
$currentstring .= '\ref{'.$href.'}'; |
|
} |
} |
return $currentstring; |
return $currentstring; |
} |
} |
|
|
#-- <li> tag |
#-- <li> tag |
sub start_li { |
sub start_li { |
my ($target,$token,$tagstack,$parstack,$safeeval) = @_; |
my ($target,$token,$tagstack,$parstack,$parser,$safeeval) = @_; |
my $currentstring = ''; |
my $currentstring = ''; |
if ($target eq 'web') { |
if ($target eq 'web') { |
$currentstring = $token->[4]; |
$currentstring = $token->[4]; |
Line 1620 sub start_dd {
|
Line 1675 sub start_dd {
|
} elsif ($target eq 'tex') { |
} elsif ($target eq 'tex') { |
if ($$tagstack[-2] eq 'dl') { |
if ($$tagstack[-2] eq 'dl') { |
$currentstring = ' \item [] '; |
$currentstring = ' \item [] '; |
|
} elsif ($$tagstack[-2] eq 'dt') { |
|
$currentstring = ']'; |
} |
} |
} |
} |
return $currentstring; |
return $currentstring; |
Line 1731 sub end_table {
|
Line 1788 sub end_table {
|
$needed=$#length_row_final-$needed+1; |
$needed=$#length_row_final-$needed+1; |
for (my $jn=0;$jn<=$#length_row_final;$jn++) { |
for (my $jn=0;$jn<=$#length_row_final;$jn++) { |
if ($length_row_final[$jn]==0) { |
if ($length_row_final[$jn]==0) { |
if ($length_raw_row[$jn]<$available_length/3) { |
if ($length_raw_row[$jn]<$available_length) { |
$length_row_final[$jn]=$length_raw_row[$jn]; |
$length_row_final[$jn]=$length_raw_row[$jn]; |
$available_length=$available_length-$length_raw_row[$jn]; |
$available_length=$available_length-$length_raw_row[$jn]; |
$needed--; |
$needed--; |
Line 1767 sub end_table {
|
Line 1824 sub end_table {
|
return $currentstring; |
return $currentstring; |
} |
} |
|
|
#-- <tr> tag |
#-- <tr> tag (end tag optional) |
sub start_tr { |
sub start_tr { |
my ($target,$token,$tagstack,$parstack,$parser,$safeeval) = @_; |
my ($target,$token,$tagstack,$parstack,$parser,$safeeval) = @_; |
my $currentstring = ''; |
my $currentstring = ''; |
Line 1801 sub end_tr {
|
Line 1858 sub end_tr {
|
return $currentstring; |
return $currentstring; |
} |
} |
|
|
#-- <td> tag |
#-- <td> tag (end tag optional) |
sub start_td { |
sub start_td { |
my ($target,$token,$tagstack,$parstack,$parser,$safeeval) = @_; |
my ($target,$token,$tagstack,$parstack,$parser,$safeeval) = @_; |
my $currentstring = ''; |
my $currentstring = ''; |
Line 1837 sub end_td {
|
Line 1894 sub end_td {
|
if ($data=~m/width\s*=\s*(\d+\.?\d*\s*(mm|cm|in|pc|pt)*)/) { |
if ($data=~m/width\s*=\s*(\d+\.?\d*\s*(mm|cm|in|pc|pt)*)/) { |
my $current_length=&recalc($1); |
my $current_length=&recalc($1); |
$current_length=~/(\d+\.?\d*)/; |
$current_length=~/(\d+\.?\d*)/; |
$Apache::londefdef::table[-1]{'TeXlength'} .= $1.','; |
$Apache::londefdef::table[-1]{'TeXlength'} .= $1.','; |
$Apache::londefdef::table[-1]{'length'} .= '0,'; |
$Apache::londefdef::table[-1]{'length'} .= '0,'; |
} else { |
} else { |
$data=~s/^\s+(\S.*)/$1/; |
$data=~s/^\s+(\S.*)/$1/; |
$data=~s/(.*\S)\s+$/$1/; |
$data=~s/(.*\S)\s+$/$1/; |
my $current_length=2*length($data); |
$data=~s/(\s)+/$1/; |
$Apache::londefdef::table[-1]{'length'} .= $current_length.','; |
my $current_length=0; |
$Apache::londefdef::table[-1]{'TeXlength'} .= '0,'; |
if ($data=~/\\vskip/) { |
} |
my $newdata=$data; |
} |
$newdata=~s/\\vskip \d*\.?\d*\s*mm/THISISJUSTTEMPORARYSEPARATOR/g; |
|
my @newdata=split(/THISISJUSTTEMPORARYSEPARATOR/,$newdata); |
|
foreach my $elementdata (@newdata) { |
|
$elementdata=~s/^\s+(\S.*)/$1/; |
|
$elementdata=~s/(.*\S)\s+$/$1/; |
|
$elementdata=~s/(\s)+/$1/; |
|
my $lengthnewdata=1.8*length($elementdata); |
|
if ($lengthnewdata>$current_length) {$current_length=$lengthnewdata;} |
|
} |
|
} else { |
|
$current_length=1.8*length($data); |
|
} |
|
$Apache::londefdef::table[-1]{'length'} .= $current_length.','; |
|
$Apache::londefdef::table[-1]{'TeXlength'} .= '0,'; |
|
} |
for (my $in=0; $in<=$#{$Apache::londefdef::table[-1]{'include'}};$in++) { |
for (my $in=0; $in<=$#{$Apache::londefdef::table[-1]{'include'}};$in++) { |
$data=~s/\\keephidden\{NEW TABLE ENTRY\}/$Apache::londefdef::table[-1]{'include'}[$in]/; |
$data=~s/\\keephidden\{NEW TABLE ENTRY\}/$Apache::londefdef::table[-1]{'include'}[$in]/; |
} |
} |
Line 1855 sub end_td {
|
Line 1926 sub end_td {
|
return $currentstring; |
return $currentstring; |
} |
} |
|
|
#-- <th> tag |
#-- <th> tag (end tag optional) |
sub start_th { |
sub start_th { |
my ($target,$token,$tagstack,$parstack,$parser,$safeeval) = @_; |
my ($target,$token,$tagstack,$parstack,$parser,$safeeval) = @_; |
my $currentstring = ''; |
my $currentstring = ''; |
Line 1921 sub start_img {
|
Line 1992 sub start_img {
|
my $width_param = ''; |
my $width_param = ''; |
my $height_param = ''; |
my $height_param = ''; |
my $scaling = .3; |
my $scaling = .3; |
|
|
if ($target eq 'web') { |
if ($target eq 'web') { |
if ($ENV{'browser.imagesuppress'} ne 'on') { |
if ($ENV{'browser.imagesuppress'} ne 'on') { |
$currentstring = $token->[4]; |
$currentstring.= $token->[4]; |
} else { |
} else { |
my $alttag= &Apache::lonxml::get_param |
my $alttag= &Apache::lonxml::get_param |
('alt',$parstack,$safeeval,undef,1); |
('alt',$parstack,$safeeval,undef,1); |
Line 1932 sub start_img {
|
Line 2002 sub start_img {
|
$alttag=&Apache::lonmeta::alttag |
$alttag=&Apache::lonmeta::alttag |
($Apache::lonxml::pwd[-1],$src); |
($Apache::lonxml::pwd[-1],$src); |
} |
} |
$currentstring='[IMAGE: '.$alttag.']'; |
$currentstring.='[IMAGE: '.$alttag.']'; |
} |
} |
} elsif ($target eq 'tex') { |
} elsif ($target eq 'tex') { |
$src=&Apache::lonnet::filelocation($Apache::lonxml::pwd[-1],$src); |
$src=&Apache::lonnet::filelocation($Apache::lonxml::pwd[-1],$src); |
&image_replication($src); |
&image_replication($src); |
|
|
#if original gif/jpg/png file exist do following: |
#if original gif/jpg/png file exist do following: |
if (-e $src) { |
if (-e $src) { |
#defines the default size of image |
#defines the default size of image |
Line 1962 sub start_img {
|
Line 2031 sub start_img {
|
} elsif ($width ne '') { |
} elsif ($width ne '') { |
$width_param = $width*$scaling; |
$width_param = $width*$scaling; |
} |
} |
|
if ($width_param > $ENV{'form.textwidth'}) {$width_param =0.95*$ENV{'form.textwidth'}} |
my $file; |
my $file; |
my $path; |
my $path; |
if ($src =~ m!(.*)/([^/]*)$!) { |
if ($src =~ m!(.*)/([^/]*)$!) { |
Line 2987 sub end_tbody {
|
Line 3057 sub end_tbody {
|
return $currentstring; |
return $currentstring; |
} |
} |
|
|
#-- <tfoot> tag |
#-- <tfoot> tag (end tag optional) |
sub start_tfoot { |
sub start_tfoot { |
my ($target,$token) = @_; |
my ($target,$token) = @_; |
my $currentstring = ''; |
my $currentstring = ''; |
Line 3006 sub end_tfoot {
|
Line 3076 sub end_tfoot {
|
return $currentstring; |
return $currentstring; |
} |
} |
|
|
#-- <thead> tag |
#-- <thead> tag (end tag optional) |
sub start_thead { |
sub start_thead { |
my ($target,$token) = @_; |
my ($target,$token) = @_; |
my $currentstring = ''; |
my $currentstring = ''; |