diff html.xsl @ 34:93fd0d532754

fix bug in refs wrt e.g. [1]!.SGX, adapt html and ascii to new-format refs, move a2n and n2a into separate files for re-use
author Henry S. Thompson <ht@markup.co.uk>
date Wed, 12 Apr 2017 21:35:04 +0100
parents 104ef815b0b0
children 5b2333e59d91
line wrap: on
line diff
--- a/html.xsl	Wed Apr 12 17:43:54 2017 +0100
+++ b/html.xsl	Wed Apr 12 21:35:04 2017 +0100
@@ -4,15 +4,20 @@
  <xsl:strip-space elements="e:a"/>
  <xsl:output omit-xml-declaration="yes"/>
  
+ <xsl:include href="n2a.xsl"/>
+
  <xsl:template match="/">
   <html>
    <head>
+    <meta http-equiv="Content-type" content="text/html; charset=utf-8"/>
     <style>
        body {font-family: 'DejaVu Sans Mono' , monospace}
        td {padding: 0}
        .e {color: red}
        .formula {font-style: italic}
        .reffed {border: solid 1px black}
+       table {table-layout: fixed}
+       th {width: 1en}
     </style>
    </head>
    <body>
@@ -22,8 +27,15 @@
  </xsl:template>
 
  <xsl:template match="e:a">
+  <xsl:variable name="n" select="count(e:r[1]/e:c)"/>
   <table>
-   <thead/>
+   <thead>
+   <tr>
+    <xsl:for-each select="1 to $n">
+     <th/>
+    </xsl:for-each>
+   </tr>
+   </thead>
    <tbody><xsl:apply-templates/></tbody>
   </table>
  </xsl:template>
@@ -36,15 +48,15 @@
  <xsl:template match="e:c">
   <td>
    <xsl:choose>
-    <xsl:when test="text()">
+    <xsl:when test="e:t">
      <xsl:attribute name="class">
-      <xsl:value-of select="(.,
+      <xsl:value-of select="(e:t,
                              if (@f) then 'formula' else (),
-                             if (@r) then 'reffed' else ())"/>
+                             if (e:r) then 'reffed' else ())"/>
      </xsl:attribute>
-     <xsl:if test="@r"><xsl:attribute name="title"><xsl:value-of select="@r"/></xsl:attribute></xsl:if>
-     <xsl:value-of select="."/></xsl:when>
-    <xsl:otherwise><xsl:text> </xsl:text></xsl:otherwise>
+     <xsl:attribute name="title"><xsl:value-of select="e:n2a(@c)"/><xsl:value-of select="../@r"/><xsl:if test="e:r">: <xsl:value-of select="e:r"/></xsl:if></xsl:attribute>
+     <xsl:value-of select="if (e:t/@c) then e:t/@c else e:t"/></xsl:when>
+    <xsl:otherwise></xsl:otherwise>
    </xsl:choose>
    </td>
  </xsl:template>