--- loncom/xml/lontexconvert.pm 2008/11/24 17:17:51 1.91
+++ loncom/xml/lontexconvert.pm 2011/02/10 20:07:00 1.98.2.1
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# TeX Conversion Module
#
-# $Id: lontexconvert.pm,v 1.91 2008/11/24 17:17:51 jms Exp $
+# $Id: lontexconvert.pm,v 1.98.2.1 2011/02/10 20:07:00 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -47,7 +47,8 @@ use Apache::lonlocal;
use Apache::lonnet;
use lib '/home/httpd/lib/perl/';
use LONCAPA;
-
+use URI::Escape;
+use IO::Socket::INET;
# ====================================================================== Header
@@ -241,16 +242,52 @@ sub init_math_support {
return;
}
+sub mimetex_valign {
+ my ($esc_texstring)=@_;
+ my $valign = 0;
+ my $lonhost = $Apache::lonnet::perlvar{'lonHostID'};
+ my $hostname = &Apache::lonnet::hostname($lonhost);
+ my $path = '/cgi-bin/mimetex.cgi?'.$esc_texstring;
+ my $socket;
+ &Apache::lonxml::start_alarm();
+ my $socket = IO::Socket::INET->new(PeerAddr => $hostname,
+ PeerPort => 'http(80)',
+ Proto => 'tcp');
+ if ($socket) {
+ my $headreq = "HEAD $path HTTP/1.0\r\n\r\n";
+ print $socket $headreq;
+ while (<$socket>) {
+ if (/Vertical\-Align\:\s*?([\-\d]+)/) {
+ $valign = $1;
+ }
+ }
+ $socket->close();
+ }
+ &Apache::lonxml::end_alarm();
+ return $valign;
+}
+
sub mimetex_converted {
my $texstring=shift;
+
+# Alt-Argument for screen readers
+ my $alt_string=$$texstring;
+ $alt_string=~s/\"/\'\'/g;
+
+# Is this displaystyle?
+
my $displaystyle=&displaystyle($texstring);
+# Remove math environment delimiters
+
&clean_out_math_mode($texstring);
if ($displaystyle) {
$$texstring='\\displaystyle \\Large '.$$texstring;
}
- my $result='';
+ my $esc_texstring = &uri_escape($$texstring);
+ my $valign = &mimetex_valign($esc_texstring);
+ my $result='
';
if ($displaystyle) {
$result='