--- loncom/xml/londefdef.pm 2001/11/29 19:03:58 1.34 +++ loncom/xml/londefdef.pm 2002/01/17 17:42:34 1.40 @@ -1,7 +1,7 @@ # 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.40 2002/01/17 17:42:34 albertel Exp $ # # Copyright Michigan State University Board of Trustees # @@ -45,13 +45,13 @@ package Apache::londefdef; use strict; use Apache::lonxml; -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')); } -#===================================================================== TAG SUBROUTINES +#======================= TAG SUBROUTINES ===================== #-- sub start_output { my ($target) = @_; @@ -70,13 +70,18 @@ sub start_m { if ($target eq 'web') { 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 = ""; @@ -93,14 +98,30 @@ sub end_m { } return $currentstring; } -#-------------------------------------------------------------------------- tag +#-- tag sub start_html { my ($target,$token) = @_; - my $currentstring = ''; + 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') { + $currentstring .= '\documentclass[letterpaper]{article} + \setlength{\oddsidemargin}{-40pt} + \setlength{\evensidemargin}{-60pt} + \setlength{\topmargin}{200pt} + \setlength{\textwidth}{4.4in} + \setlength{\textheight}{6.8in} + \setlength{\parindent}{20pt} + \setlength{\marginparwidth}{90pt} + \setlength{\textfloatsep}{8pt plus 2.0pt minus 4.0pt} + \newcommand{\keephidden}[1]{}'; + } return $currentstring; } sub end_html { @@ -108,10 +129,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 = ''; @@ -129,7 +150,7 @@ sub end_m { } return $currentstring; } -#--------------------------------------------------------------------------- tag +#-- tag sub start_map { my ($target,$token) = @_; my $currentstring = ''; @@ -146,8 +167,7 @@ sub end_m { } return $currentstring; } - -#------------------------------------------------------------------------ tag sub start_select { my ($target,$token) = @_; my $currentstring = ''; @@ -164,7 +184,7 @@ sub end_m { } return $currentstring; } -#------------------------------------------------------------------------