--- loncom/xml/lontexconvert.pm 2016/02/20 00:12:45 1.118 +++ loncom/xml/lontexconvert.pm 2019/02/15 20:56:22 1.122 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # TeX Conversion Module # -# $Id: lontexconvert.pm,v 1.118 2016/02/20 00:12:45 raeburn Exp $ +# $Id: lontexconvert.pm,v 1.122 2019/02/15 20:56:22 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -271,11 +271,19 @@ sub displaystyle { sub MathJax_converted { my $texstring=shift; - my $tag='math/tex;'; - if (&displaystyle($texstring)) { $tag='math/tex; mode=display'; } + my ($tag,$startspan,$endspan); + $tag='math/tex;'; + if (&displaystyle($texstring)) { + $tag='math/tex; mode=display'; + $startspan=''; + $endspan=''; + } else { + $startspan=''; + $endspan=''; + } &clean_out_math_mode($texstring); - return &MathJax_header(). - ''; + return &MathJax_header().$startspan. + ''.$endspan; } { @@ -313,7 +321,7 @@ sub tex_engine { if (exists($env{'form.texengine'})) { if ($env{'form.texengine'} ne '') { if (lc($env{'form.texengine'}) eq 'jsmath') { - return 'MathJax'; + return 'MathJax'; } return $env{'form.texengine'}; } @@ -331,7 +339,12 @@ sub tex_engine { } return $env{'environment.texengine'}; } - return 'tth'; + my $dom = $env{'request.role.domain'} || $env{'user.domain'}; + my %domdefaults = &Apache::lonnet::get_domain_defaults($dom); + if ($domdefaults{'texengine'} ne '') { + return $domdefaults{'texengine'}; + } + return $Apache::lonnet::deftex; } sub init_math_support { @@ -548,7 +561,7 @@ sub postprocess_algebra { # $string =~s/\\fun/ /g; # sqrt(3,4) means the 4 root of 3 - $string =~s/\\sqrt{([^,]+),([^\}]+)}/\\sqrt[$2]{$1}/gs; + $string =~s/\\sqrt\{([^,]+),([^\}]+)}/\\sqrt[$2]{$1}/gs; # log(3,4) means the log base 4 of 3 $string =~s/\\log\\left\((.+?),(.+?)\\right\)/\\log_{$2}\\left($1\\right)/gs;