--- loncom/xml/londefdef.pm 2001/11/29 19:03:58 1.34 +++ loncom/xml/londefdef.pm 2002/02/21 04:29:27 1.43 @@ -1,7 +1,8 @@ # 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.43 2002/02/21 04:29:27 albertel Exp $ +# # # Copyright Michigan State University Board of Trustees # @@ -39,19 +40,20 @@ # # 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 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')); + &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','pre')); } -#===================================================================== TAG SUBROUTINES +#======================= TAG SUBROUTINES ===================== #-- sub start_output { my ($target) = @_; @@ -70,13 +72,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 +100,31 @@ sub end_m { } 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') { + $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]{} + \usepackage[dvips]{graphicx}'; + } return $currentstring; } sub end_html { @@ -108,10 +132,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 +153,7 @@ sub end_m { } return $currentstring; } -#--------------------------------------------------------------------------- tag +#-- tag sub start_map { my ($target,$token) = @_; my $currentstring = ''; @@ -146,8 +170,7 @@ sub end_m { } return $currentstring; } - -#------------------------------------------------------------------------ tag sub start_select { my ($target,$token) = @_; my $currentstring = ''; @@ -164,7 +187,7 @@ sub end_m { } return $currentstring; } -#------------------------------------------------------------------------