[LON-CAPA-cvs] cvs: loncom /xml lontexconvert.pm

foxr lon-capa-cvs-allow@mail.lon-capa.org
Tue, 29 Jan 2008 11:04:11 -0000


foxr		Tue Jan 29 06:04:11 2008 EDT

  Modified files:              
    /loncom/xml	lontexconvert.pm 
  Log:
  BZ5593 - postprocess converted latex so that 
         \rightleftharpoons -> ⇔ which is a 
         double left/right arrow and is going to have to be
         close enough.
  
  
Index: loncom/xml/lontexconvert.pm
diff -u loncom/xml/lontexconvert.pm:1.84 loncom/xml/lontexconvert.pm:1.85
--- loncom/xml/lontexconvert.pm:1.84	Tue Aug 14 15:32:35 2007
+++ loncom/xml/lontexconvert.pm	Tue Jan 29 06:04:10 2008
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # TeX Conversion Module
 #
-# $Id: lontexconvert.pm,v 1.84 2007/08/14 19:32:35 albertel Exp $
+# $Id: lontexconvert.pm,v 1.85 2008/01/29 11:04:10 foxr Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -85,6 +85,7 @@
 # into the safe space since opcode checks only occur at compile time
 sub convert_real {
     my ($texstring)=@_;
+    &Apache::lonnet::logthis("convert_real converting '$$texstring");
     my ($xmlstring,$errorstring);
     local $SIG{SEGV}=sub { $Apache::lontexconvert::messedup=1; die; };
     local $SIG{ALRM}=sub { 
@@ -95,12 +96,14 @@
     };
     &Apache::lonxml::start_alarm();
     if ($env{'browser.mathml'}) {
+	&Apache::lonnet::logthis("mathml translation");
 	$xmlstring=&tth::ttm($$texstring);
 	$xmlstring=~s/\<math\>/\<math xmlns=\"\&mathns\;\"\>/g;
 	$xmlstring=~s/\<br\>/\<br\/\>/g;
 	$xmlstring=~s/\<p\>/\<p\>\<\/p\>/g;
 	$errorstring.=&tth::ttmerror();
     } else {
+	&Apache::lonnet::logthis("tth translation");
 	$xmlstring=&tth::tth($$texstring);
 	$errorstring.=&tth::ttherror();
 	$xmlstring=~s-</font(\s*)>-</font>-g;
@@ -108,6 +111,14 @@
     $xmlstring=~s/^\s*\<br clear\=\"all\"/\<br/s;
     $xmlstring=~s/^\s*//;
     $xmlstring=~s/\s*$//;
+    #
+    # \rightleftharpoons is not converted by tth but maps
+    # reasonably well to &#8660;.  If we get many more of these,
+    # we're going to need to have a translation sub.
+    #
+    $xmlstring=~s/\\rightleftharpoons/\&\#8660;/g;
+
+    &Apache::lonnet::logthis("Final result: $xmlstring");
     &Apache::lonxml::end_alarm();
     return ($xmlstring,$errorstring);
 }