[LON-CAPA-cvs] cvs: loncom /homework structuretags.pm /interface loncommon.pm /xml londefdef.pm lontexconvert.pm
albertel
lon-capa-cvs@mail.lon-capa.org
Tue, 05 Jul 2005 18:59:07 -0000
albertel Tue Jul 5 14:59:07 2005 EDT
Modified files:
/loncom/interface loncommon.pm
/loncom/homework structuretags.pm
/loncom/xml londefdef.pm lontexconvert.pm
Log:
- adding support for resource author to specify a rendering engine
<m display="tth"> for instance
Index: loncom/interface/loncommon.pm
diff -u loncom/interface/loncommon.pm:1.268 loncom/interface/loncommon.pm:1.269
--- loncom/interface/loncommon.pm:1.268 Thu Jun 30 13:56:28 2005
+++ loncom/interface/loncommon.pm Tue Jul 5 14:59:03 2005
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# a pile of common routines
#
-# $Id: loncommon.pm,v 1.268 2005/06/30 17:56:28 albertel Exp $
+# $Id: loncommon.pm,v 1.269 2005/07/05 18:59:03 albertel Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -2728,11 +2728,9 @@
<body bgcolor="$pgbg" text="$font" alink="$alink" vlink="$vlink" link="$link"
style="margin-top: 0px;$addstyle" $addentries>
END
+ &Apache::lontexconvert::jsMath_reset();
if ($env{'environment.texengine'} eq 'jsMath') {
- $bodytag.='<script type="text/javascript">
- function NoFontMessage () {}
- </script>'."\n".
- '<script src="/adm/jsMath/jsMath.js"></script>'."\n";
+ $bodytag.=&Apache::lontexconvert::jsMath_header();
}
my $upperleft='<img src="http://'.$ENV{'HTTP_HOST'}.':'.
@@ -2879,10 +2877,7 @@
sub endbodytag {
my $endbodytag='</body>';
- if ($env{'environment.texengine'} eq 'jsMath') {
- $endbodytag='<script type="text/javascript">jsMath.Process()</script>'.
- "\n".$endbodytag;
- }
+ $endbodytag=&Apache::lontexconvert::jsMath_process()."\n".$endbodytag;
return $endbodytag;
}
Index: loncom/homework/structuretags.pm
diff -u loncom/homework/structuretags.pm:1.296 loncom/homework/structuretags.pm:1.297
--- loncom/homework/structuretags.pm:1.296 Tue Jun 28 15:56:10 2005
+++ loncom/homework/structuretags.pm Tue Jul 5 14:59:03 2005
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# definition of tags that give a structure to a document
#
-# $Id: structuretags.pm,v 1.296 2005/06/28 19:56:10 albertel Exp $
+# $Id: structuretags.pm,v 1.297 2005/07/05 18:59:03 albertel Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -88,11 +88,10 @@
$body_tag_start.=' style="font-size: x-large;" ';
}
$body_tag_start.='>'.&Apache::lonmenu::menubuttons(undef,$target,1);
+
+ &Apache::lontexconvert::jsMath_reset();
if ($env{'environment.texengine'} eq 'jsMath') {
- $body_tag_start.='<script type="text/javascript">
- function NoFontMessage () {}
- </script>'."\n".
- '<script src="/adm/jsMath/jsMath.js"></script>'."\n";
+ $body_tag_start.=&Apache::lontexconvert::jsMath_header();
}
return $body_tag_start;
}
@@ -119,8 +118,10 @@
my $body_tag_start;
if (!defined($found{'body'}) && $env{'request.state'} eq 'construct'
&& $env{'environment.remote'} eq 'off') {
- $body_tag_start=&Apache::loncommon::bodytag();
- $body_tag_start.=&Apache::lonxml::message_location();
+ if ($target eq 'web') {
+ $body_tag_start=&Apache::loncommon::bodytag();
+ $body_tag_start.=&Apache::lonxml::message_location();
+ }
} elsif (!defined($found{'body'})) {
my $background=&Apache::lonxml::get_param('background',$parstack,
$safeeval);
Index: loncom/xml/londefdef.pm
diff -u loncom/xml/londefdef.pm:1.275 loncom/xml/londefdef.pm:1.276
--- loncom/xml/londefdef.pm:1.275 Mon May 23 05:49:36 2005
+++ loncom/xml/londefdef.pm Tue Jul 5 14:59:03 2005
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Tags Default Definition Module
#
-# $Id: londefdef.pm,v 1.275 2005/05/23 09:49:36 foxr Exp $
+# $Id: londefdef.pm,v 1.276 2005/07/05 18:59:03 albertel Exp $
#
#
# Copyright Michigan State University Board of Trustees
@@ -90,7 +90,8 @@
$inside=&Apache::run::evaluate($inside,$safeeval,$$parstack[-1]);
#&Apache::lonxml::debug("M is evaulated to:$inside:");
}
- $currentstring = &Apache::lontexconvert::converted(\$inside);
+ my $display=&Apache::lonxml::get_param('display',$parstack,$safeeval);
+ $currentstring = &Apache::lontexconvert::converted(\$inside,$display);
if ($Apache::lontexconvert::errorstring) {
&Apache::lonxml::warning("tth error: ".
$Apache::lontexconvert::errorstring);
Index: loncom/xml/lontexconvert.pm
diff -u loncom/xml/lontexconvert.pm:1.66 loncom/xml/lontexconvert.pm:1.67
--- loncom/xml/lontexconvert.pm:1.66 Wed Jun 8 22:17:11 2005
+++ loncom/xml/lontexconvert.pm Tue Jul 5 14:59:03 2005
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# TeX Conversion Module
#
-# $Id: lontexconvert.pm,v 1.66 2005/06/09 02:17:11 albertel Exp $
+# $Id: lontexconvert.pm,v 1.67 2005/07/05 18:59:03 albertel Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -165,7 +165,28 @@
my $tag='span';
if (&displaystyle($texstring)) { $tag='div'; }
&clean_out_math_mode($texstring);
- return '<'.$tag.' class="math">'.$$texstring.'</'.$tag.'>';
+ return &jsMath_header().
+ '<'.$tag.' class="math">'.$$texstring.'</'.$tag.'>';
+}
+
+{
+ my $jsMath_sent_header;
+ sub jsMath_reset {
+ $jsMath_sent_header=0;
+ }
+ sub jsMath_header {
+ return '' if $jsMath_sent_header;
+ $jsMath_sent_header=1;
+ return
+ '<script type="text/javascript">
+ function NoFontMessage () {}
+ </script>'."\n".
+ '<script src="/adm/jsMath/jsMath.js"></script>'."\n";
+ }
+ sub jsMath_process {
+ return '' if !$jsMath_sent_header;
+ return '<script type="text/javascript">jsMath.Process()</script>';
+ }
}
sub mimetex_converted {
@@ -185,14 +206,16 @@
}
sub converted {
- if ($env{'environment.texengine'} eq 'tth') {
- return &tth_converted;
- } elsif ($env{'environment.texengine'} eq 'jsMath') {
- return &jsMath_converted;
- } elsif ($env{'environment.texengine'} eq 'mimetex') {
- return &mimetex_converted;
+ my ($string,$mode)=@_;
+ if ($mode eq '') { $mode=$env{'environment.texengine'}; }
+ if ($mode eq 'tth') {
+ return &tth_converted($string);
+ } elsif ($mode eq 'jsMath') {
+ return &jsMath_converted($string);
+ } elsif ($mode eq 'mimetex') {
+ return &mimetex_converted($string);
}
- return &tth_converted;
+ return &tth_converted($string);
}
# ====================================================================== Footer