File:  [LON-CAPA] / loncom / xml / lontexconvert.pm
Revision 1.112.2.1: download - view: text, annotated - select for diffs
Thu May 10 19:19:30 2012 UTC (12 years, 1 month ago) by raeburn
Branches: version_2_11_X
- For 2.11.
  - Reverse changes in 1.109. MathJax not in 2.11.0.

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

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