]> matita.cs.unibo.it Git - helm.git/blobdiff - helm/style/content_to_html.xsl
1. Fixati alcuni problemi di indentazione con le rewrite.
[helm.git] / helm / style / content_to_html.xsl
index 1211e4881be96e555eba8e9d9245832cff02fdb8..399ab10191e99f5b942f096d85e7594d3b9a7ecd 100644 (file)
       <head>
         <title> <xsl:value-of select="$CICURI"/> </title> <!-- FG -->
          <style> A { text-decoration: none } </style>
+         <script>
+          <xsl:text disable-output-escaping="yes">
+           <![CDATA[
+            function Hide(which){
+             if (!document.getElementById)
+              return
+             which.style.display="none"
+            }
+
+            function Show(which){
+             if (!document.getElementById)
+              return
+             which.style.display=""
+            }
+
+            document.to_be_deleted = new Array();
+          ]]>
+          </xsl:text>
+         </script>
       </head>
       <body bgcolor="white">
+         <xsl:attribute name="onLoad">
+          if(document.getElementById)
+           for(var i=0;i&lt;document.to_be_deleted.length;i++)
+            Hide(document.getElementById(document.to_be_deleted[i]));
+         </xsl:attribute>
          <xsl:apply-templates>
             <xsl:with-param name="current_indent" select="0"/>
          </xsl:apply-templates>
       <!-- ***************************************** -->
       <!-- PROOF -->
       <xsl:when test="$name='proof'">
-       <xsl:apply-templates select="*[position()=2]">
-        <xsl:with-param name="current_indent" select="$current_indent"/>
-       </xsl:apply-templates>
-       <br/>
-       <!-- <xsl:element name="br"/> -->
-       <xsl:call-template name="make_indent">
-        <xsl:with-param name="current_indent" select="$current_indent"/> 
-       </xsl:call-template>
-       <FONT color="red">we proved&#x00a0;</FONT>
+       <xsl:variable name="nonce" select="generate-id()"/>
+       <xsl:variable name="freshid1" select="concat('a',$nonce)"/>
+       <xsl:variable name="freshid2" select="concat('b',$nonce)"/>
+       <xsl:variable name="freshid3" select="concat('c',$nonce)"/>
+       <span ID="{$freshid1}">
+        <xsl:apply-templates select="*[position()=2]">
+         <xsl:with-param name="current_indent" select="$current_indent"/>
+        </xsl:apply-templates>
+        &#x00a0;
+       </span>
+       <xsl:choose>
+        <xsl:when test="(preceding-sibling::*[1]/text()='letin1') or
+                        (preceding-sibling::*[1]/text()='rw_step')">
+         <br/>
+         <xsl:call-template name="make_indent">
+          <xsl:with-param name="current_indent" select="$current_indent"/>
+         </xsl:call-template>
+         <FONT color="red">we proved&#x00a0;</FONT> 
+        </xsl:when>
+        <xsl:otherwise>
+         <script>
+          if(document.getElementById) {
+           document.write('\
+            <span ID="{$freshid2}">\
+             <a style="text-decoration:underline ; color:green" href="" onClick="Show(document.getElementById(\'{$freshid1}\')); Hide(document.getElementById(\'{$freshid2}\'));Show(document.getElementById(\'{$freshid3}\'));return (0==1);">Proof of</a>\
+            </span>\
+            <span ID="{$freshid3}">\
+             <br/>\
+             <xsl:call-template name="make_indent">
+              <xsl:with-param name="current_indent" select="$current_indent"/>
+             </xsl:call-template>\
+             <a style="text-decoration:underline ; color:red" href="" onClick="Hide(document.getElementById(\'{$freshid1}\')); Show(document.getElementById(\'{$freshid2}\'));Hide(document.getElementById(\'{$freshid3}\'));return (0==1);">we proved</a>\
+            </span>\
+           ');
+           document.to_be_deleted.push('<xsl:value-of select="$freshid1"/>');
+           document.to_be_deleted.push('<xsl:value-of select="$freshid3"/>');
+           document.write('&#x00a0;');
+          } else {
+           document.write('\
+            <br/>\
+            <xsl:call-template name="make_indent">
+             <xsl:with-param name="current_indent" select="$current_indent"/>
+            </xsl:call-template>\
+            <FONT color="red">we proved&#x00a0;</FONT>\
+           ');
+          }
+         </script>
+        </xsl:otherwise>
+       </xsl:choose>
        <xsl:apply-templates select="*[position()=3]">
         <xsl:with-param name="current_indent" select="$current_indent + 16"/>
        </xsl:apply-templates>
         </xsl:otherwise>
        </xsl:choose>
        <xsl:variable name="charlength_first">
-        <xsl:apply-templates select="*[3]/*[1]" mode="charcount"/>
+        <xsl:apply-templates select="*[3]" mode="root_charcount"/>
        </xsl:variable>
        <xsl:variable name="charlength_second">
-        <xsl:apply-templates select="*[4]/*[1]" mode="charcount"/>
+        <xsl:apply-templates select="*[4]" mode="root_charcount"/>
        </xsl:variable>
        <xsl:variable name="charlength_side_proof">
-        <xsl:apply-templates select="*[5]/*[1]" mode="charcount"/>
+        <xsl:apply-templates select="*[5]" mode="root_charcount"/>
        </xsl:variable>
        <xsl:variable name="split1"
-          select="$charlength_first + $charlength_second > $framewidth"/>
+         select="($charlength_first + $charlength_second) > $framewidth"/>
        <xsl:variable name="split2"
-          select="$charlength_second + $charlength_side_proof > $framewidth"/>
+         select="($charlength_second + $charlength_side_proof) > $framewidth"/>
      <!-- <xsl:value-of select="$current_indent"/> -->
-     <!-- <xsl:value-of select="$charlength"/> -->
+     <!-- <xsl:value-of select="string($charlength_second)"/>  -->
+     <!-- <xsl:value-of select="$charlength_side_proof"/>  -->
+     <!-- <xsl:value-of select="$split2"/>  -->
        <br/>
        <xsl:call-template name="make_indent">
         <xsl:with-param name="current_indent" select="$current_indent"/> 
  </xsl:choose>
 </xsl:template>
 
-<!-- COUNTING -->
+<!-- CHAR COUNTING -->
+
+<!-- enter this counting mode selecting the root -->
+<xsl:template match="*" mode="root_charcount">
+<xsl:param name="incurrent_length" select="0"/>
+ <xsl:choose>
+  <xsl:when test="count(*)=0">
+   <xsl:value-of select="0"/>
+  </xsl:when>
+  <xsl:when test="name()='m:ci'">
+   <xsl:value-of select="string-length()"/>
+  </xsl:when>
+  <xsl:otherwise>
+   <xsl:apply-templates select="*[1]" mode="charcount">
+    <xsl:with-param name="incurrent_length" select="$incurrent_length"/>
+   </xsl:apply-templates>
+  </xsl:otherwise>
+ </xsl:choose>
+</xsl:template>
+
+<!-- enter this mode selecting the first child --> 
 
 <xsl:template match="m:ci|m:csymbol" mode="charcount">
 <xsl:param name="incurrent_length" select="0"/>