Update of /cvsroot/aimmath/moodle/lib/t2mml
In directory sc8-pr-cvs1:/tmp/cvs-serv25804/lib/t2mml
Modified Files:
ctop.xsl edit.php pmathml.xsl pmathmlcss.xsl
Log Message:
edit.php now recognizes \[ and \(. Also updated stylesheets from w3c.org
Index: ctop.xsl
===================================================================
RCS file: /cvsroot/aimmath/moodle/lib/t2mml/ctop.xsl,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** ctop.xsl 17 Sep 2003 19:22:19 -0000 1.1
--- ctop.xsl 27 Sep 2003 09:16:32 -0000 1.2
***************
*** 1176,1181 ****
<xsl:apply-templates mode="c2p" select="*[1]"/>
</xsl:template>
! <xsl:template mode="c2p" match="mml:semantics[annotation-xml/@encoding='MathML-Presentation']">
! <xsl:apply-templates mode="c2p" select="annotation-xml[@encoding='MathML-Presentation']/node()"/>
</xsl:template>
--- 1176,1181 ----
<xsl:apply-templates mode="c2p" select="*[1]"/>
</xsl:template>
! <xsl:template mode="c2p" match="mml:semantics[mml:annotation-xml/@encoding='MathML-Presentation']">
! <xsl:apply-templates mode="c2p" select="mml:annotation-xml[@encoding='MathML-Presentation']/node()"/>
</xsl:template>
Index: edit.php
===================================================================
RCS file: /cvsroot/aimmath/moodle/lib/t2mml/edit.php,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** edit.php 25 Sep 2003 22:12:05 -0000 1.2
--- edit.php 27 Sep 2003 09:16:32 -0000 1.3
***************
*** 73,89 ****
if ((ereg(">",$b)) || ($b=="}")){
if (substr($expr,$i,1)=="/"){
! $numerateur=strrchr(substr($expr,0,$i+2),"<");
! $i=$i-strlen($numerateur)+1;
} else {
! if ($b==">") $b=strrchr(substr($expr,0,$i+2),"<");
! $i=$i-strlen($b)+1;
! $balisefin=$b;
! if ($b!="}") $balisedebut=str_replace("/","",$b); else $balisedebut="{";
! $c=chercherbo($balisedebut,$balisefin,substr($expr,0,$i+1));
! $i=$i-strlen($c.$balisedebut);
! $c=indiceexposant($c);
! if ($balisedebut!="{") $balisedebutN=$balisedebut; else $balisedebutN="<mrow>";
! if ($balisefin!="}") $balisefinN=$balisefin; else $balisefinN="</mrow>";
! $numerateur=$c;
}
$ok=true;
--- 73,89 ----
if ((ereg(">",$b)) || ($b=="}")){
if (substr($expr,$i,1)=="/"){
! $numerateur=strrchr(substr($expr,0,$i+2),"<");
! $i=$i-strlen($numerateur)+1;
} else {
! if ($b==">") $b=strrchr(substr($expr,0,$i+2),"<");
! $i=$i-strlen($b)+1;
! $balisefin=$b;
! if ($b!="}") $balisedebut=str_replace("/","",$b); else $balisedebut="{";
! $c=chercherbo($balisedebut,$balisefin,substr($expr,0,$i+1));
! $i=$i-strlen($c.$balisedebut);
! $c=indiceexposant($c);
! if ($balisedebut!="{") $balisedebutN=$balisedebut; else $balisedebutN="<mrow>";
! if ($balisefin!="}") $balisefinN=$balisefin; else $balisefinN="</mrow>";
! $numerateur=$c;
}
$ok=true;
***************
*** 98,117 ****
$exprr=substr($exprr,strlen($balisedebut.$c.$balisefin),strlen($exprr));
if (($balisedebut=="<msup>") && (ereg("\_",$a))){
! $baliseO="<msubsup>";
! $baliseF="</msubsup>";
! $balisedebut="";
! $balisefin="";
} else {
! if (ereg("\_",$a)) {
! $baliseO="<msub>";
! $baliseF="</msub>";
! } else {
! $baliseO="<msup>";
! $baliseF="</msup>";
! }
} $denominateur=$balisedebut.$c.$balisefin;
} else $ok=false;
if ($ok) {
! $exprr=$baliseO.$balisedebutN.$numerateur.$balisefinN.$denominateur.$baliseF.$exprr;
$a="";
} else $i=$j;
--- 98,117 ----
$exprr=substr($exprr,strlen($balisedebut.$c.$balisefin),strlen($exprr));
if (($balisedebut=="<msup>") && (ereg("\_",$a))){
! $baliseO="<msubsup>";
! $baliseF="</msubsup>";
! $balisedebut="";
! $balisefin="";
} else {
! if (ereg("\_",$a)) {
! $baliseO="<msub>";
! $baliseF="</msub>";
! } else {
! $baliseO="<msup>";
! $baliseF="</msup>";
! }
} $denominateur=$balisedebut.$c.$balisefin;
} else $ok=false;
if ($ok) {
! $exprr=$baliseO.$balisedebutN.$numerateur.$balisefinN.$denominateur.$baliseF.$exprr;
$a="";
} else $i=$j;
***************
*** 204,220 ****
$c=strrchr(substr($expr,0,$i+2),"<");
if ((!(ereg("<mo",$c))) || (!($c))) {
! $i=$i-strlen($b)+1;
! if (($commande!="sqrt") && ($commande!="frac")) {
! $exprr="<mo>&#".$commande.";</mo>".$exprr;
! } else
! $exprr="\\".$commande."".$exprr;
} else {
! $exprr=str_replace("\\".$commande,"&#".$commande.";",$c).$exprr;
! // echo "c=$c\n";
! //echo "exprr=$exprr\n";
! $i=$i-strlen($c)+1;
! //$a=substr($expr,$i,1);
! //echo "a=$a\n";
! //$a="";
}
$a="";
--- 204,220 ----
$c=strrchr(substr($expr,0,$i+2),"<");
if ((!(ereg("<mo",$c))) || (!($c))) {
! $i=$i-strlen($b)+1;
! if (($commande!="sqrt") && ($commande!="frac")) {
! $exprr="<mo>&#".$commande.";</mo>".$exprr;
! } else
! $exprr="\\".$commande."".$exprr;
} else {
! $exprr=str_replace("\\".$commande,"&#".$commande.";",$c).$exprr;
! // echo "c=$c\n";
! //echo "exprr=$exprr\n";
! $i=$i-strlen($c)+1;
! //$a=substr($expr,$i,1);
! //echo "a=$a\n";
! //$a="";
}
$a="";
***************
*** 336,339 ****
--- 336,342 ----
$message=preg_replace("/(\\$){2}([^$]+)(\\$){2}/e","'<div align=\"center\"><math xmlns=\"http://www.w3.org/1998/Math/MathML\"><mstyle displaystyle=\"true\">'.editermaths(\"$2\").'</mstyle></math></div>'",$message);
$message=preg_replace("/(\\$){1}([^$]+)(\\$){1}/e","'<math xmlns=\"http://www.w3.org/1998/Math/MathML\">'.editermaths(\"$2\").'</math>'",$message);
+ $message=preg_replace("/(\\\\\[)([^$]+)(\\\\\])/e","'<div align=\"center\"><math xmlns=\"http://www.w3.org/1998/Math/MathML\"><mstyle displaystyle=\"true\">'.editermaths(\"$2\").'</mstyle></math></div>'",$message);
+ $message=preg_replace("/(\\\\\()([^$]+)(\\\\\))/e","'<math xmlns=\"http://www.w3.org/1998/Math/MathML\">'.editermaths(\"$2\").'</math>'",$message);
+
$fflag++;
}
Index: pmathml.xsl
===================================================================
RCS file: /cvsroot/aimmath/moodle/lib/t2mml/pmathml.xsl,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** pmathml.xsl 17 Sep 2003 19:22:19 -0000 1.1
--- pmathml.xsl 27 Sep 2003 09:16:32 -0000 1.2
***************
*** 48,53 ****
<fns:x name="css" o="Microsoft.FreeThreadedXMLDOM">
! <script for="window" event="onload">
var xsl = new ActiveXObject("Microsoft.FreeThreadedXMLDOM");
xsl.async = false;
--- 48,57 ----
+ <!-- SCRIPT not script due to weird mozilla bug
+ http://bugzilla.mozilla.org/show_bug.cgi?id=158457
+ -->
+
<fns:x name="css" o="Microsoft.FreeThreadedXMLDOM">
! <SCRIPT for="window" event="onload">
var xsl = new ActiveXObject("Microsoft.FreeThreadedXMLDOM");
xsl.async = false;
***************
*** 65,69 ****
var newDoc = document.open("text/html", repl);
newDoc.write(str);
! </script>
</fns:x>
--- 69,73 ----
var newDoc = document.open("text/html", repl);
newDoc.write(str);
! </SCRIPT>
</fns:x>
***************
*** 194,203 ****
<fns:x name="techexplorer-plugin" >techexplorer-plugin</fns:x>
! <xsl:variable name="docpref" select="document('')/*/fns:x[@name=current()/*/@fns:renderer][1]"/>
<xsl:param name="activex">
<xsl:choose>
! <xsl:when test="$docpref='techexplorer-plugin'">techexplorer-plugin</xsl:when>
<xsl:when test="system-property('xsl:vendor')!='Microsoft'"/>
<xsl:when test="$docpref='mathplayer-dl'">mathplayer-dl</xsl:when>
<xsl:when test="$docpref and fns:isinstalled(string($docpref/@o))='true'">
--- 198,212 ----
<fns:x name="techexplorer-plugin" >techexplorer-plugin</fns:x>
! <xsl:variable name="root" select="/"/>
!
!
<xsl:param name="activex">
<xsl:choose>
! <xsl:when test="/*/@fns:renderer='techexplorer-plugin'">techexplorer-plugin</xsl:when>
<xsl:when test="system-property('xsl:vendor')!='Microsoft'"/>
+ <xsl:otherwise>
+ <xsl:variable name="docpref" select="document('')/*/fns:x[@name=$root/*/@fns:renderer][1]"/>
+ <xsl:choose>
<xsl:when test="$docpref='mathplayer-dl'">mathplayer-dl</xsl:when>
<xsl:when test="$docpref and fns:isinstalled(string($docpref/@o))='true'">
***************
*** 208,211 ****
--- 217,222 ----
</xsl:otherwise>
</xsl:choose>
+ </xsl:otherwise>
+ </xsl:choose>
</xsl:param>
***************
*** 318,324 ****
<xsl:when doc:id="mp" test="$activex='mathplayer-dl'">
<xsl:if test="fns:isinstalled('MathPlayer.Factory.1')='false'">
! <script for="window" event="onload">
<xsl:value-of select="$mpdialog" disable-output-escaping="yes"/>
! </script>
</xsl:if>
<xsl:copy-of select="document('')/*/fns:x[@name='mathplayer']"/>
--- 329,335 ----
<xsl:when doc:id="mp" test="$activex='mathplayer-dl'">
<xsl:if test="fns:isinstalled('MathPlayer.Factory.1')='false'">
! <SCRIPT for="window" event="onload">
<xsl:value-of select="$mpdialog" disable-output-escaping="yes"/>
! </SCRIPT>
</xsl:if>
<xsl:copy-of select="document('')/*/fns:x[@name='mathplayer']"/>
***************
*** 354,357 ****
--- 365,372 ----
+ <!-- squash annotation elements -->
+
+
+
<h:p>Somewhat bizarrely in an otherwise namespace aware system,
Microsoft behaviours are defined to trigger off the
***************
*** 367,370 ****
--- 382,403 ----
</xsl:template>
+ <h:p>Copy semantics element through in IE (so mathplayer gets to see
+ mathplayer annotations, otherwise use first child or a presentation annotation.</h:p>
+ <xsl:template match="mml:semantics">
+ <xsl:choose>
+ <xsl:when test="system-property('xsl:vendor')='Microsoft'">
+ <xsl:element name="mml:{local-name(.)}">
+ <xsl:copy-of select="@*"/>
+ <xsl:apply-templates/>
+ </xsl:element>
+ </xsl:when>
+ <xsl:when test="mml:annotation-xml[@encoding='MathML-Presentation']">
+ <xsl:apply-templates select="mml:annotation-xml[@encoding='MathML-Presentation']/node()"/>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:apply-templates select="*[1]"/>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:template>
<!-- a version of my old verb.xsl -->
Index: pmathmlcss.xsl
===================================================================
RCS file: /cvsroot/aimmath/moodle/lib/t2mml/pmathmlcss.xsl,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
|