--- loncom/xml/londefdef.pm 2001/11/29 19:03:58 1.34 +++ loncom/xml/londefdef.pm 2002/05/22 21:07:45 1.62 @@ -1,7 +1,9 @@ + # The LearningOnline Network with CAPA # Tags Default Definition Module # -# $Id: londefdef.pm,v 1.34 2001/11/29 19:03:58 www Exp $ +# $Id: londefdef.pm,v 1.62 2002/05/22 21:07:45 sakharuk Exp $ +# # # Copyright Michigan State University Board of Trustees # @@ -39,19 +41,22 @@ # # last modified 06/26/00 by Alexander Sakharuk # 11/6,11/30,02/01/01,5/4 Gerd Kortemeyer +# 01/18 Alex Sakharuk package Apache::londefdef; +use Apache::lonnet; use strict; use Apache::lonxml; +use Apache::File(); -sub BEGIN { +BEGIN { - &Apache::lonxml::register('Apache::londefdef',('m','html','head','map','select','option','input','textarea','form','meta','title','body','center','b','strong','table','dt','h1','h2','h3','h4','h5','h6','cite','i','address','dd','dl','dir','ol','ul','menu','dfn','kbd','tt','code','em','q','p','br','big','small','basefont','font','s','sub','strike','sup','hr','a','li','u','output','param','applet','img','embed','tr','td','allow','frameset')); + &Apache::lonxml::register('Apache::londefdef',('m','html','head','map','select','option','input','textarea','form','meta','title','body','center','b','strong','dt','h1','h2','h3','h4','h5','h6','cite','i','address','dd','dl','dir','ol','ul','menu','dfn','kbd','tt','code','em','q','p','br','big','small','basefont','font','s','sub','strike','sup','hr','a','li','u','output','param','applet','img','embed','allow','frameset','pre','insert','externallink','table','tr','th','td')); } -#===================================================================== TAG SUBROUTINES +#======================= TAG SUBROUTINES ===================== #-- sub start_output { my ($target) = @_; @@ -68,15 +73,21 @@ sub start_m { my ($target,$token,$tagstack,$parstack,$parser,$safeeval) = @_; my $currentstring = ''; if ($target eq 'web') { + $Apache::lonxml::prevent_entity_encode++; my $inside = &Apache::lonxml::get_all_text("/m",$$parser[-1]); $inside ='\\documentstyle{article}'.$inside; - #&Apache::lonxml::debug("M is starting with:$inside:"); + &Apache::lonxml::debug("M is starting with:$inside:"); my $eval=&Apache::lonxml::get_param('eval',$parstack,$safeeval); if ($eval eq 'on') { $inside=&Apache::run::evaluate($inside,$safeeval,$$parstack[-1]); #&Apache::lonxml::debug("M is evaulated to:$inside:"); } $currentstring = &Apache::lontexconvert::converted(\$inside); + if ($Apache::lontexconvert::errorstring) { + &Apache::lonxml::warning("tth error: ". + $Apache::lontexconvert::errorstring); + $Apache::lontexconvert::errorstring=''; + } #&Apache::lonxml::debug("M is ends with:$currentstring:"); } elsif ($target eq 'tex') { $currentstring = ""; @@ -87,20 +98,32 @@ sub end_m { my ($target,$token) = @_; my $currentstring = ''; if ($target eq 'web') { + $Apache::lonxml::prevent_entity_encode--; } elsif ($target eq 'tex') { $currentstring = ""; } elsif ($target eq 'meta') { } return $currentstring; } -#-------------------------------------------------------------------------- tag +#-- 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} + \newcommand{\keephidden}[1]{} + \usepackage[dvips]{graphicx} + \usepackage{epsfig}'; + } return $currentstring; } sub end_html { @@ -108,10 +131,10 @@ sub end_m { my $currentstring = ''; if ($target eq 'web') { $currentstring = &Apache::lonxml::xmlend(); - } + } return $currentstring; } -#-------------------------------------------------------------------------- tag +#-- tag sub start_head { my ($target,$token) = @_; my $currentstring = ''; @@ -124,12 +147,12 @@ sub end_m { my ($target,$token) = @_; my $currentstring = ''; if ($target eq 'web') { - $currentstring = &Apache::lonxml::registerurl(). + $currentstring = &Apache::lonxml::registerurl(undef,$target). $token->[2]; } return $currentstring; } -#--------------------------------------------------------------------------- tag +#-- tag sub start_map { my ($target,$token) = @_; my $currentstring = ''; @@ -146,8 +169,7 @@ sub end_m { } return $currentstring; } - -#------------------------------------------------------------------------ tag sub start_select { my ($target,$token) = @_; my $currentstring = ''; @@ -164,7 +186,7 @@ sub end_m { } return $currentstring; } -#------------------------------------------------------------------------