File:  [LON-CAPA] / loncom / xml / lontexconvert.pm
Revision 1.110: download - view: text, annotated - select for diffs
Tue Feb 28 10:38:14 2012 UTC (12 years, 3 months ago) by foxr
Branches: MAIN
CVS tags: HEAD
BZ 5837 -
  1. Add table of conversion string -> unicode equivalents and
     sub to do a conversion.
  2. Use this to turn the entities generated by tth to unicode bracket
segment characters directly.

    1: # The LearningOnline Network with CAPA
    2: # TeX Conversion Module
    3: #
    4: # $Id: lontexconvert.pm,v 1.110 2012/02/28 10:38:14 foxr Exp $
    5: #
    6: # Copyright Michigan State University Board of Trustees
    7: #
    8: # This file is part of the LearningOnline Network with CAPA (LON-CAPA).
    9: #
   10: # LON-CAPA is free software; you can redistribute it and/or modify
   11: # it under the terms of the GNU General Public License as published by
   12: # the Free Software Foundation; either version 2 of the License, or
   13: # (at your option) any later version.
   14: #
   15: # LON-CAPA is distributed in the hope that it will be useful,
   16: # but WITHOUT ANY WARRANTY; without even the implied warranty of
   17: # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   18: # GNU General Public License for more details.
   19: #
   20: # You should have received a copy of the GNU General Public License
   21: # along with LON-CAPA; if not, write to the Free Software
   22: # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
   23: #
   24: # /home/httpd/html/adm/gpl.txt
   25: #
   26: # http://www.lon-capa.org/
   27: #
   28: # Copyright for TtHfunc and TtMfunc by Ian Hutchinson. 
   29: # TtHfunc and TtMfunc (the "Code") may be compiled and linked into 
   30: # binary executable programs or libraries distributed by the 
   31: # Michigan State University (the "Licensee"), but any binaries so 
   32: # distributed are hereby licensed only for use in the context
   33: # of a program or computational system for which the Licensee is the 
   34: # primary author or distributor, and which performs substantial 
   35: # additional tasks beyond the translation of (La)TeX into HTML.
   36: # The C source of the Code may not be distributed by the Licensee
   37: # to any other parties under any circumstances.
   38: #
   39: 
   40: package Apache::lontexconvert;
   41: 
   42: use strict;
   43: use tth();
   44: use vars qw($errorstring);
   45: #use Apache::lonxml();
   46: use Apache::lonlocal;
   47: use Apache::lonnet;
   48: use lib '/home/httpd/lib/perl/';
   49: use LONCAPA;
   50: use URI::Escape;
   51: use IO::Socket::INET;
   52: 
   53: 
   54: #
   55: # Table of substitutions to unicode characters.
   56: #
   57: my %unicode_translations = (
   58:     '\rightleftharpoons'  => 0x21cc,
   59:     ''             => 0x23a1,
   60:     ''             => 0x23a2,
   61:     ''             => 0x23a3,
   62:     ''             => 0x23a4,
   63:     ''             => 0x23a5,
   64:     ''             => 0x23a6   
   65: );
   66: 
   67: ##
   68: # Utility to convert elements of a string to unicode:
   69: #
   70: # @param input - Input string
   71: # @param pattern - Pattern to convert
   72: # @param unicode - Unicode to substitute for pattern.
   73: #
   74: # @return string - resulting string.
   75: # 
   76: sub unicode_subst {
   77:     my ($input, $pattern, $unicode) = @_;
   78:     
   79:     my $char = pack('U', $unicode);
   80: 
   81:     $input =~ s/$pattern/$char/g;
   82: 
   83:     return $input;
   84: }
   85: 
   86: # ====================================================================== Header
   87: 
   88: sub init_tth {
   89:     my $options=$env{'course.'.$env{'request.course.id'}.'.tthoptions'};
   90:     if ($options =~ /\S/) {
   91: 	$options = ' '.$options;
   92:     } else {
   93: 	undef($options);
   94:     }
   95:     if ($env{'browser.mathml'}) {
   96: 	&tth::ttminit();
   97: 	if ($env{'browser.unicode'}) {
   98: 	    &tth::ttmoptions('-L -u1'.$options);
   99: 	} else {
  100: 	    &tth::ttmoptions('-L -u0'.$options);
  101: 	}
  102:     } else {
  103: 	&tth::tthinit();
  104: 	if ($env{'browser.unicode'}) {
  105: 	    &tth::tthoptions('-L -u1'.$options);
  106: 	} else {
  107: 	    &tth::tthoptions('-L -u0'.$options);
  108: 	}
  109:     }
  110: }
  111: 
  112: # ================================================================== Conversion
  113: 
  114: $Apache::lontexconvert::messedup=0;
  115: 
  116: 
  117: sub convert_real {
  118:     my ($texstring)=@_;
  119:     my ($xmlstring,$errorstring);
  120:     local $SIG{SEGV}=sub { $Apache::lontexconvert::messedup=1; die; };
  121:     local $SIG{ALRM}=sub { 
  122: 	&Apache::lonnet::logthis("ALRM");
  123: 	$xmlstring='['.&mt("TeX unconverted due to errors").']';
  124: 	$Apache::lontexconvert::messedup=1;
  125: 	die &mt("TeX unconverted due to errors");
  126:     };
  127:     &Apache::lonxml::start_alarm();
  128:     if ($env{'browser.mathml'}) {
  129: 	&Apache::lonnet::logthis("mathml");
  130: 	$xmlstring=&tth::ttm($$texstring);
  131: 	$xmlstring=~s/\<math\>/\<math xmlns=\"\&mathns\;\"\>/g;
  132: 	$xmlstring=~s/\<br\>/\<br\/\>/g;
  133: 	$xmlstring=~s/\<p\>/\<p\>\<\/p\>/g;
  134: 	$errorstring.=&tth::ttmerror();
  135:     } else {
  136: 	&Apache::lonnet::logthis("tth");
  137: 	$xmlstring=&tth::tth($$texstring);
  138: 	$errorstring.=&tth::ttherror();
  139: 	$xmlstring=~s-</font(\s*)>-</font>-g;
  140:     }
  141:     $xmlstring=~s/^\s*\<br clear\=\"all\"/\<br/s;
  142:     $xmlstring=~s/^\s*//;
  143:     $xmlstring=~s/\s*$//;
  144:     &Apache::lonxml::end_alarm();
  145: 
  146:     #
  147:     #  Several strings produced by tth require
  148:     # transliteration -> unicode equivalents to render reliably
  149:     # in browsers. %unicode_translations is a table of
  150:     # string->substitution which we now apply:
  151: 
  152:     foreach my $pattern (keys(%unicode_translations)) {
  153: 	my $unicode = $unicode_translations{$pattern};
  154: 	$xmlstring = &unicode_subst($xmlstring, $pattern, $unicode);
  155:     }
  156: 
  157: 
  158:     return ($xmlstring,$errorstring);
  159: }
  160: 
  161: sub tth_converted {
  162:     my $texstring=shift;
  163:     my $xmlstring='['.&mt('UNDISPLAYABLE').']';
  164:     if ($Apache::lontexconvert::messedup) {
  165: 	return '['.&mt('TeX unconverted due to previous errors').']';
  166:     }
  167:     $$texstring ='\\documentstyle{article}'.$$texstring;
  168: 
  169:     eval(<<'ENDCONV');
  170:     ($xmlstring,$errorstring)=&convert_real($texstring)
  171: ENDCONV
  172:     if ($@) {
  173: 	$errorstring.=&mt("Evaluation Error: ").$@;
  174: 	$Apache::lontexconvert::messedup=1;
  175:     }
  176:     if ($Apache::lontexconvert::messedup || &tth::tthmessedup() || 
  177: 	$errorstring) {
  178: 	&Apache::lonnet::logthis("Trying to kill myself");
  179: 	$Apache::lontexconvert::messedup=1;
  180: 	if (ref($Apache::lonxml::request)) {
  181: 	    $Apache::lonxml::request->child_terminate();
  182: 	} else {
  183: 	    my $request;
  184: 	    eval { $request=Apache->request; };
  185: 	    if (!$request) {
  186: 		eval { $request=Apache2::RequestUtil->request; };
  187: 	    }
  188: 	    if ($request) {
  189: 		$request->child_terminate();
  190: 	    } else {
  191: 		&Apache::lonnet::logthis("Unable to find a request to do child_terminate on");
  192: 	    }
  193: 	}
  194:     }
  195:     return $xmlstring;
  196: }
  197: 
  198: sub clean_out_math_mode {
  199:     my ($texstring)=@_;
  200:     $$texstring=~s/(?<!\\)\$//g;
  201:     $$texstring=~s/\\[\)\(\]\[]//g;
  202:     $$texstring=~s/\\ensuremath//g;
  203:     return '';
  204: }
  205: 
  206: sub displaystyle {
  207:     my ($texstring)=@_;
  208:     #has a $$ or \[ or \displaystyle or eqnarray in it, guessinng it's display mode
  209:     if ($$texstring=~/[^\\]\$\$/ ||
  210:         $$texstring=~/\\\[/ ||
  211:         $$texstring=~/\\displaystyle/ ||
  212:         $$texstring=~/eqnarray/
  213:        ) { return 1; }
  214:     return 0;
  215: }
  216: 
  217: sub MathJax_converted {
  218:     my $texstring=shift;
  219:     my $tag='math/tex;';
  220:     if (&displaystyle($texstring)) { $tag='math/tex; mode=display'; }
  221:     &clean_out_math_mode($texstring);
  222:     return &MathJax_header().
  223:       '<script type="'.$tag.'">'.$$texstring.'</script>';
  224: }
  225: 
  226: {
  227:     #Relies heavily on the previous jsMath installation
  228:     my @MathJax_sent_header;
  229:     sub MathJax_reset {
  230:         undef(@MathJax_sent_header);
  231:     }
  232:     sub MathJax_push {
  233:         push(@MathJax_sent_header,0);
  234:     }
  235:     sub MathJax_header {
  236:         if (!@MathJax_sent_header) {
  237:             &Apache::lonnet::logthis("mismatched calls of MathJax_header and MathJax_process");
  238:             return '';
  239:         }
  240:         return '' if $MathJax_sent_header[-1];
  241:         $MathJax_sent_header[-1]=1;
  242:         return
  243:           '<script type="text/javascript" src="/adm/MathJax/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script>'."\n";
  244:     }
  245:     #sub MathJax_process {
  246:     #    my $state = pop(@MathJax_sent_header);
  247:     #    return '' if !$state;
  248:     #    return "\n".
  249:     #        '<script type="text/javascript">MathJax.Process()</script>'."\n";
  250:     #}
  251:     #sub MathJax_state {
  252:     #    my ($level) = @_;
  253:     #    return $MathJax_sent_header[$level];
  254:     #}
  255: }
  256: 
  257: 
  258: sub jsMath_converted {
  259:     my $texstring=shift;
  260:     my $tag='span';
  261:     if (&displaystyle($texstring)) { $tag='div'; }
  262:     &clean_out_math_mode($texstring);
  263:     return &jsMath_header().
  264: 	'<'.$tag.' class="math">'.$$texstring.'</'.$tag.'>';
  265: }
  266: 
  267: {
  268:     my @jsMath_sent_header;
  269:     sub jsMath_reset {
  270: 	undef(@jsMath_sent_header);
  271:     }
  272:     sub jsMath_push {
  273: 	push(@jsMath_sent_header,0);
  274:     }
  275:     sub jsMath_header {
  276: 	if (!@jsMath_sent_header) {
  277: 	    &Apache::lonnet::logthis("mismatched calls of jsMath_header and jsMath_process");
  278: 	    return '';
  279: 	}
  280: 	return '' if $jsMath_sent_header[-1];
  281: 	$jsMath_sent_header[-1]=1;
  282: 	return
  283:             '<script type="text/javascript">
  284:                      function NoFontMessage () {}
  285:                      jsMath = {Parser: {prototype: {environments: {\'eqnarray*\' :[\'Array\',null,null,\'rcl\',[5/18,5/18],3,\'D\']}}}};
  286:                    </script>'."\n".
  287: 	    '<script type="text/javascript" src="/adm/jsMath/jsMath.js"></script>'."\n";
  288:     }
  289:     sub jsMath_process {
  290: 	my $state = pop(@jsMath_sent_header);
  291: 	return '' if !$state;
  292: 	return "\n".
  293: 	    '<script type="text/javascript">jsMath.Process()</script>'."\n";
  294:     }
  295:     sub jsMath_state {
  296: 	my ($level) = @_;
  297: 	return $jsMath_sent_header[$level];
  298:     }
  299: }
  300: 
  301: sub tex_engine {
  302:     if (exists($env{'form.texengine'})) {
  303: 	if ($env{'form.texengine'} ne '') {
  304:             return $env{'form.texengine'};
  305:         }
  306:     }    
  307:     if ($env{'request.course.id'}
  308: 	&& exists($env{'course.'.$env{'request.course.id'}.'.texengine'})) {
  309: 	return $env{'course.'.$env{'request.course.id'}.'.texengine'};
  310:     }
  311:     if (exists($env{'environment.texengine'})) {
  312: 	return $env{'environment.texengine'};
  313:     }
  314:     return 'tth';
  315: }
  316: 
  317: sub init_math_support {
  318:     my ($inherit_jsmath) = @_;
  319:     &init_tth();
  320:     &Apache::lontexconvert::jsMath_push();
  321:     if (lc(&tex_engine()) eq 'jsmath' ||
  322: 	($inherit_jsmath && &jsMath_state(-2))) {
  323: 	return &Apache::lontexconvert::jsMath_header();
  324:     }
  325:     &Apache::lontexconvert::MathJax_push();
  326:     if (lc(&tex_engine()) eq 'mathjax') { # ||
  327:         #($inherit_jsmath && &jsMath_state(-2))) {
  328:         return &Apache::lontexconvert::MathJax_header();
  329:     }
  330:     return;
  331: }
  332: 
  333: sub mimetex_valign {
  334:     my ($esc_texstring)=@_;
  335:     my $valign = 0;
  336:     my $path = '/cgi-bin/mimetex.cgi?'.$esc_texstring;
  337:     my $socket;
  338:     &Apache::lonxml::start_alarm();
  339:     $socket = IO::Socket::INET->new(PeerAddr => 'localhost',
  340:                                     PeerPort => 'http(80)',
  341:                                     Proto    => 'tcp');
  342:     if ($socket) {
  343:         my $headreq = "HEAD $path HTTP/1.0\r\n\r\n";
  344:         print $socket $headreq;
  345:         while (<$socket>) {
  346:             if (/Vertical\-Align\:\s*?([\-\d]+)/) {
  347:                 $valign = $1;
  348:             }
  349:         }
  350:         $socket->close();
  351:     }
  352:     &Apache::lonxml::end_alarm();
  353:     return $valign;
  354: }
  355: 
  356: sub mimetex_converted {
  357:     my $texstring=shift;
  358: 
  359: # Alt-Argument for screen readers
  360:     my $alt_string=$$texstring;
  361:     $alt_string=~s/\"/\'\'/g;
  362: 
  363: # Is this displaystyle?
  364: 
  365:     my $displaystyle=&displaystyle($texstring);
  366: 
  367: # Remove math environment delimiters
  368: 
  369:     &clean_out_math_mode($texstring);
  370: 
  371:     if ($displaystyle) {
  372: 	$$texstring='\\displaystyle \\Large '.$$texstring;
  373:     }
  374:     my $esc_texstring = &uri_escape($$texstring);
  375:     my $valign = &mimetex_valign($esc_texstring);
  376:     my $result='<img src="/cgi-bin/mimetex.cgi?'.$esc_texstring.'" style="vertical-align:'.$valign.'px" alt="'.$alt_string.'" />';
  377:     if ($displaystyle) {
  378: 	$result='<div style="text-align:center">'.$result.'</div>';
  379:     }
  380:     return $result;
  381: }
  382: 
  383: sub converted {
  384:     my ($string,$mode)=@_;
  385:     if ($mode eq '') { $mode = &tex_engine(); }
  386:     if ($mode =~ /tth/i) {
  387: 	return &tth_converted($string);
  388:     } elsif ($mode =~ /jsmath/i) {
  389: 	return &jsMath_converted($string);
  390:     } elsif ($mode =~ /mathjax/i) {
  391: 	return &MathJax_converted($string);
  392:     } elsif ($mode =~ /mimetex/i) {
  393: 	return &mimetex_converted($string);
  394:     } elsif ($mode =~ /raw/i) {
  395:         return $$string;
  396:     }
  397:     return &tth_converted($string);
  398: }
  399: 
  400: # ------------------------------------------------------------ Message display
  401: 
  402: sub to_convert {
  403:     my ($string) = @_;
  404:     &init_tth();
  405:     $string=~s/\<br\s*\/?\>/ /gs;
  406: #    $string=~s/\s/ /gs;
  407:     $string=&HTML::Entities::decode($string);
  408:     return &converted(\$string);
  409: }
  410: 
  411: sub smiley {
  412:     my $expression=shift;
  413:     my %smileys=(
  414:     	 '\:\-*\)' => 'face-smile.png',
  415: 		 '8\-\)'  => 'face-cool.png',
  416: 		 '8\-(I|\|)'   => 'face-glasses.png',
  417: 		 '\:\-(I|\|)'   => 'face-plain.png',
  418: 		 '\:\-(o|O|\(\))' => 'face-surprise.png',
  419: 		 ':\-\('  => 'face-sad.png',
  420: 		 '\;\-\)' => 'face-wink.png',
  421: 		 '\:\-(P|p)'  => 'face-raspberry.png',
  422: 		 '\:\-(\\\|\\/)' => 'face-uncertain.png',
  423: 		 '\:\-D'  => 'face-smile-big.png',
  424: 		 '\:\-(C|\@)'  => 'face-angry.png',
  425: 		 '\:(\'|\`)\-*\(' => 'face-crying.png',
  426: 		 '\:\-(X|x|\#)' => 'face-quiet.png',
  427: 		 '\:\-(s|S)' => 'face-uncertain.png',
  428: 		 '\:\-\$' => 'face-embarrassed.png',
  429: 		 '\:\-\*' => 'face-kiss.png',
  430: 		 '\+O\(' => 'face-sick.png',
  431: 		 '(\&lt\;3|\(heart\))' => 'heart.png',
  432: 		 '\(rose\)' => 'rose.png',
  433: 		 '\(pizza\)' => 'food-pizza.png',
  434: 		 '\(cake\)' => 'food-cake.png',
  435: 		 '\(ninja\)' => 'face-ninja.png',
  436: 		 '\(pirate\)' => 'face-pirate.png',
  437: 		 '\((agree|yes)\)' => 'opinion-agree.png',
  438: 		 '\((disagree|nay)\)' => 'opinion-disagree.png',
  439: 		 '(o|O)\-\)' => 'face-angel.png',
  440: 		 );
  441:     my $iconpath=$Apache::lonnet::perlvar{'lonIconsURL'};
  442:     foreach my $smiley (keys(%smileys)) {
  443: 	$expression=~s/$smiley/\<img src="$iconpath\/$smileys{$smiley}" \/\>/gs; 
  444:     }
  445:     return $expression;
  446: }
  447: 
  448: sub msgtexconverted {
  449:     my ($message,$email) = @_;
  450:     $errorstring='';
  451:     my $outmessage='';
  452:     my $tex=0;
  453:     foreach my $fragment (split(/(?:\&lt\;|\<)\/*m\s*(?:\&gt\;|\>)/i,$message)) {
  454: 	if ($tex) {
  455: 	    if ($email) {
  456: 		$outmessage.='</pre><tt>'.&to_convert($fragment).'</tt><pre>';
  457: 		$tex=0;
  458: 	    } else {
  459: 		$outmessage.=&to_convert($fragment);
  460: 		$tex=0;
  461: 	    }
  462: 	} else {
  463:             $outmessage.=&smiley($fragment);
  464: 	    $tex=1;
  465: 	}
  466:     }
  467:     $message=$outmessage; $outmessage=''; $tex=0;
  468:     foreach my $fragment (split(/(?:\&lt\;|\<)\/*algebra\s*(?:\&gt\;|\>)/i,
  469: 				$message)) {
  470: 	if ($tex) {
  471:         my $algebra = &algebra($fragment, 'web', undef, undef, undef, undef, 'tth');
  472: 	    if ($email) {
  473: 		$outmessage.='</pre><tt>'.$algebra.'</tt><pre>';
  474: 		$tex=0;
  475: 	    } else {
  476: 		$outmessage.=$algebra;
  477: 		$tex=0;
  478: 	    }
  479: 	} else {
  480:         $outmessage.=$fragment;
  481: 	    $tex=1;
  482: 	}
  483:     }
  484:     if (wantarray) {
  485: 	return ($outmessage,$errorstring);
  486:     } else {
  487: 	return $outmessage.$errorstring;
  488:     }
  489: }
  490: 
  491: sub algebra {
  492:     use AlgParser;
  493:     my ($string,$target,$style,$parstack,$safeeval,$tth)=@_;
  494:     my $parser = new AlgParserWithImplicitExpand;
  495:     if ($tth eq 'tth') {&init_tth();}
  496:     $string=&prepare_algebra($string);
  497:     my $ret = $parser->parse($string);
  498:     my $result='['.&mt('Algebra unconverted due to previous errors').']';
  499:     if ( ref($ret) ) {
  500: 	#$parser->tostring();
  501: 	$parser->normalize();
  502: 	my $latex=$parser->tolatex();
  503: 	$latex=&postprocess_algebra($latex);
  504: 	if ($style eq 'display') {
  505: 	    $latex='$$'.$latex.'$$x';
  506: 	} else {
  507: 	    # style is 'inline'
  508: 	    $latex='\\ensuremath{'.$latex.'}';
  509: 	}
  510: 	if ($target eq 'web' || $target eq 'analyze') {
  511:             my $display=&Apache::lonxml::get_param('display',$parstack,$safeeval);
  512:             $result = &converted(\$latex,$display);
  513: #	    $result = &converted(\$latex);
  514: 	} else {
  515: 	    $result = $latex;
  516: 	}
  517:     } else {
  518: 	&Apache::lonxml::error($parser->{'htmlerror'});
  519:     }
  520: }
  521: 
  522: sub prepare_algebra {
  523:     my ($string)=@_;
  524: 
  525:     # makes the decision about what is a minus sign easier supposedly
  526:     $string =~ s/(\<\>|\<\=|\>\=[\=\>\<] *)-/$1 zeroplace -/g;
  527: 
  528:     return $string;
  529: }
  530: 
  531: sub postprocess_algebra {
  532:     my ($string)=@_;
  533:     
  534:     # moodle had these and I don't know why, ignoring them for now
  535:     # $string =~s/\\fun/ /g;
  536: 
  537:     # sqrt(3,4) means the 4 root of 3
  538:     $string =~s/\\sqrt{([^,]+),([^\}]+)}/\\sqrt[$2]{$1}/gs;
  539: 
  540:     # log(3,4) means the log base 4 of 3
  541:     $string =~s/\\log\\left\((.+?),(.+?)\\right\)/\\log_{$2}\\left($1\\right)/gs;
  542: 
  543:     # log(3,4) means the log base 4 of 3
  544:     $string =~s/\\((?:sin|cos|tan|sec|csc|cot)(?:h)?)\\left\((.+?),(.+?)\\right\)/\\$1^{$3}\\left($2\\right)/gs;
  545: 
  546:     # int(3,a,b) integral from a to b of 3
  547:     $string =~s/\\int\\left\((.+?),(.+?),(.+?)\\right\)/\\int_{$2}^{$3}\\left($1\\right)/gs;
  548: 
  549:     # int( ... dx) -> ...
  550:     $string =~s/\\int\\left\((.+?)d[a-z]\\right\)/$1/gs;
  551: 
  552:     # 
  553:     $string =~s/\\lim\\left\((.+?),(.+?),(.+?)\\right\)/\\lim_{$2\\to $3}$1/gs;
  554:     return $string;
  555: }
  556: 1;
  557: __END__
  558: 
  559: 
  560: =pod
  561: 
  562: =head1 NAME
  563: 
  564: Apache::lontexconvert;
  565: 
  566: =head1 SYNOPSIS
  567: 
  568: Access to tth/ttm
  569: 
  570: This is part of the LearningOnline Network with CAPA project
  571: described at http://www.lon-capa.org.
  572: 
  573: 
  574: =head1 SUBROUTINES
  575: 
  576: =over
  577: 
  578: =item init_tth()
  579: 
  580: Header
  581: 
  582: =item convert_real()
  583: 
  584:  we need this routine because &converted can get called from inside
  585:  of the safespace (through &xmlparse('<m>stuff</m>') which doesn't
  586:  allow the opcode for alarm, so we need to compile this before we get
  587:  into the safe space since opcode checks only occur at compile time
  588: 
  589: =item tth_converted()
  590: 
  591: 
  592: =item clean_out_math_mode()
  593: 
  594: 
  595: =item displaystyle()
  596: 
  597: 
  598: =item jsMath_converted()
  599: 
  600: =item MathJax_converted()
  601: 	- Mimics the jsMath functionality
  602: 
  603: =item tex_engine()
  604: 
  605: 
  606: =item init_math_support()
  607: 
  608: =item mimetex_valign()
  609: 
  610:  Makes a HEAD call to /cgi-bin/mimetex.cgi via IO:: to retrieve the 
  611:  vertical alignment, before the subsequent call to mimetex_converted()
  612:  which generates the <img> tag and the corresponding image.
  613: 
  614:  Input: 1.  $esc_texstring (escaped TeX to be rendered by mimetex).
  615:  Output: 1. $valign - number of pixels: positive or negative integer 
  616:             which will be included in <img> tag for mimetex image to
  617:             support vertical alignment of image within a line of text.
  618: 
  619:  If a server is running SSL, and Apache rewrite rules are in place 
  620:  to rewrite requests for http to https, modification will most likely 
  621:  be needed for pass through for HEAD requests for /cgi-bin/mimetex.cgi. 
  622: 
  623:  Example rewrite rules which rewrite all http traffic to https, 
  624:  except HEAD requests for /cgi-bin/mimetex.cgi are:
  625: 
  626:  <IfModule mod_rewrite.c>
  627:      RewriteEngine On
  628:      RewriteLogLevel 0
  629: 
  630:      RewriteCond %{HTTPS} off
  631:      RewriteCond %{HTTP:Host} (.*)
  632:      RewriteCond %{REQUEST_METHOD} !HEAD 
  633:      RewriteRule ^/(.*) https://%1/$1 [R=301,L]
  634: 
  635:      RewriteCond %{HTTPS} off
  636:      RewriteCond %{HTTP:Host} (.*)
  637:      RewriteCond %{REQUEST_METHOD} HEAD
  638:      RewriteCond %{REQUEST_URI} !^/cgi-bin/mimetex.cgi
  639:      RewriteRule ^/(.*) https://%1/$1 [R=301,L]
  640:  </IfModule>
  641: 
  642: =item mimetex_converted()
  643: 
  644: 
  645: =item converted()
  646: 
  647: 
  648: =item to_convert()
  649: 
  650: message display
  651: 
  652: =item smiley()
  653: 
  654: ???
  655: 
  656: =item msgtexconverted()
  657: 
  658: =item algebra()
  659: 
  660: =item prepare_algebra()
  661: 
  662: =item postprocess_algebra()
  663: 
  664: =back
  665: 
  666: =cut
  667: 
  668: 
  669: 

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>