--- rat/lonpage.pm 2014/09/16 13:28:34 1.106 +++ rat/lonpage.pm 2014/12/30 20:03:19 1.107 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # Page Handler # -# $Id: lonpage.pm,v 1.106 2014/09/16 13:28:34 raeburn Exp $ +# $Id: lonpage.pm,v 1.107 2014/12/30 20:03:19 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -307,6 +307,12 @@ ENDEXT #some additional cleanup necessary for LateX (due to limitations of table environment $output =~ s/(\\vskip\s*\d+mm)\s*(\\\\)+/$1/g; } + my $matheditor; + if ($output =~ /\Qjavascript:LC_mathedit_HWVAL_\E/) { + $matheditor = 'dragmath'; + } elsif ($output =~ /LCmathField/) { + $matheditor = 'lcmath'; + } my $parser=HTML::TokeParser->new(\$output); my $token; my $thisdir=$src; @@ -373,6 +379,15 @@ ENDEXT s/\<((?:input|select|button|textarea)[^\>]+)name\s*\=\s*[\'\"]*([^\'\"]+)[\'\"]*([^\>]*)\>/\<$1 name="$prefix$2" $3\>/gsi; $output=~ s/\<((?:input|select|button|textarea)[^\>]+)id\s*\=\s*[\'\"]*([^\'\"]+)[\'\"]*([^\>]*)\>/\<$1 id="$idprefix$2" $3\>/gsi; + if ($matheditor eq 'dragmath') { + $output=~ + s/(\Qjavascript:LC_mathedit_\E)(HWVAL_)([^'"]+?)(\(['"]*)(\QHWVAL_\E\3['"]\)\;void\(0\)\;)/$1$idprefix$2$3$4$idprefix$5/g; + $output=~ + s/(function\s+LC_mathedit_)(HWVAL_)([^'"]+?)(\s+\(LCtextline\))/$1$idprefix$2$3$4/g; + } elsif ($matheditor eq 'lcmath') { + $output=~ + s/(var\s+LCmathField\s+=\s+document\.getElementById\(['"])([^'"]+?)(['"]\)\;)/$1$idprefix$2$3/g; + } $output=~ s/(\Q