]> granicus.if.org Git - docbook-dsssl/commitdiff
Patch from Joe Orton
authorNorman Walsh <ndw@nwalsh.com>
Tue, 17 Sep 2002 15:09:11 +0000 (15:09 +0000)
committerNorman Walsh <ndw@nwalsh.com>
Tue, 17 Sep 2002 15:09:11 +0000 (15:09 +0000)
contrib/xsl/db2man/db2man.xsl
contrib/xsl/db2man/synop.xsl
xsl/manpages/db2man.xsl
xsl/manpages/synop.xsl

index 21379dc7e23b6701d1b7f0e89f86cd870dd3b446..539f2a57d983027ea2deb389139f62988f8bbe63 100644 (file)
@@ -38,7 +38,7 @@
 </xsl:template>
 
 <xsl:template match="refsect2">
-  <xsl:text>&#10;.Sh "</xsl:text>
+  <xsl:text>&#10;.SS "</xsl:text>
   <xsl:value-of select="title[1]"/>
   <xsl:text>"&#10;</xsl:text>
   <xsl:apply-templates/>
index 05122660542a0f2dfc94aa105b6e1b897e0ea2e8..e5c4e37f21082fb2e01826f0989698e8417e4925 100644 (file)
 </xsl:template>
 
 <xsl:template match="void">
-  <xsl:text> (void</xsl:text>
+  <xsl:text>void</xsl:text>
 </xsl:template>
 
 <xsl:template match="varargs">
-  <xsl:text> (...</xsl:text>
+  <xsl:text>...</xsl:text>
 </xsl:template>
 
 <xsl:template match="funcsynopsisinfo">
   <xsl:text>&#10;.sp&#10;</xsl:text>
 </xsl:template>
 
+<!-- disable hyphenation, and use left-aligned filling for the duration
+     of the synopsis, so that line breaks only occur between 
+     separate paramdefs. -->
 <xsl:template match="funcsynopsis">
-  <xsl:text>.nf&#10;</xsl:text>
+  <xsl:text>.ad l&#10;.hy 0&#10;</xsl:text>
   <xsl:apply-templates/>
-  <xsl:text>.fi&#10;</xsl:text>
+  <xsl:text>.ad&#10;.hy&#10;</xsl:text>
 </xsl:template>
 
 <!-- TODO: Handle K&R-style parameter lists
           is now obsolete and thus deleted
 -->
 
+<!-- evaluates to parameter string with all space characters converted
+     to non-breaking spaces. -->
+<xsl:template name="nbspace">
+  <xsl:param name="string" select="''"/>
+  <xsl:choose>
+    <xsl:when test="contains($string, ' ')">
+      <xsl:value-of select="substring-before($string, ' ')"/>
+      <xsl:text>\ </xsl:text>
+      <xsl:call-template name="nbspace">
+       <xsl:with-param name="string" select="substring-after($string, ' ')"/>
+      </xsl:call-template>
+    </xsl:when>
+    <xsl:otherwise>
+      <xsl:value-of select="$string"/>
+    </xsl:otherwise>
+  </xsl:choose>
+</xsl:template>
+
+<!-- replaces all spaces within the funcdef/paramdef with non-breaking
+     spaces -->
+<xsl:template match="paramdef|funcdef">
+  <xsl:variable name="content">
+    <xsl:apply-templates select="*|./*|text()"/>
+  </xsl:variable>
+  <xsl:call-template name="nbspace">
+    <xsl:with-param name="string" select="$content"/>
+  </xsl:call-template>
+  <xsl:if test="local-name(.) = 'paramdef' and 
+         (following-sibling::paramdef or following-sibling::varargs)">
+    <xsl:text>, </xsl:text>
+  </xsl:if>
+</xsl:template>
+
 <xsl:template match="funcprototype">
   <xsl:variable name="funcprototype">
     <xsl:apply-templates select="funcdef"/>
   </xsl:variable>
-  <xsl:text>.sp&#10;</xsl:text>
+  <xsl:text>.HP </xsl:text>
+  <xsl:value-of select="string-length (normalize-space ($funcprototype)) - 5"/>
+  <xsl:text>&#10;</xsl:text>
   <xsl:value-of select="normalize-space ($funcprototype)"/>
-  <xsl:text> (</xsl:text>
-  <xsl:for-each select="paramdef">
-    <xsl:variable name="param">
-      <xsl:apply-templates select="." />
-    </xsl:variable>
-    <xsl:value-of select="normalize-space ($param)" />
-    <xsl:choose>
-      <xsl:when test="following-sibling::paramdef">
-       <xsl:text>,&#10;</xsl:text>
-      </xsl:when>
-      <xsl:otherwise>
-       <xsl:text>);&#10;.RE&#10;</xsl:text>
-      </xsl:otherwise>
-    </xsl:choose>
-    <xsl:if test="not (preceding-sibling::paramdef)">
-      <xsl:text>.RS </xsl:text>
-      <xsl:value-of
-       select="string-length(normalize-space ($funcprototype)) - 4" />
-      <xsl:text>&#10;</xsl:text>
-    </xsl:if>
-  </xsl:for-each>
+  <xsl:text>\ (</xsl:text>
+  <xsl:apply-templates select="void|paramdef|varargs"/>
+  <xsl:text>);&#10;</xsl:text>
 </xsl:template>
 
 </xsl:stylesheet>
index ae8eebf169865168c25a450417c5406317694e67..7e776537a4c678dd97bde22f1120d44af67a2639 100644 (file)
@@ -34,7 +34,7 @@
 </xsl:template>
 
 <xsl:template match="refsect2">
-  <xsl:text>&#10;.Sh "</xsl:text>
+  <xsl:text>&#10;.SS "</xsl:text>
   <xsl:value-of select="title[1]"/>
   <xsl:text>"&#10;</xsl:text>
   <xsl:apply-templates/>
index 05122660542a0f2dfc94aa105b6e1b897e0ea2e8..e5c4e37f21082fb2e01826f0989698e8417e4925 100644 (file)
 </xsl:template>
 
 <xsl:template match="void">
-  <xsl:text> (void</xsl:text>
+  <xsl:text>void</xsl:text>
 </xsl:template>
 
 <xsl:template match="varargs">
-  <xsl:text> (...</xsl:text>
+  <xsl:text>...</xsl:text>
 </xsl:template>
 
 <xsl:template match="funcsynopsisinfo">
   <xsl:text>&#10;.sp&#10;</xsl:text>
 </xsl:template>
 
+<!-- disable hyphenation, and use left-aligned filling for the duration
+     of the synopsis, so that line breaks only occur between 
+     separate paramdefs. -->
 <xsl:template match="funcsynopsis">
-  <xsl:text>.nf&#10;</xsl:text>
+  <xsl:text>.ad l&#10;.hy 0&#10;</xsl:text>
   <xsl:apply-templates/>
-  <xsl:text>.fi&#10;</xsl:text>
+  <xsl:text>.ad&#10;.hy&#10;</xsl:text>
 </xsl:template>
 
 <!-- TODO: Handle K&R-style parameter lists
           is now obsolete and thus deleted
 -->
 
+<!-- evaluates to parameter string with all space characters converted
+     to non-breaking spaces. -->
+<xsl:template name="nbspace">
+  <xsl:param name="string" select="''"/>
+  <xsl:choose>
+    <xsl:when test="contains($string, ' ')">
+      <xsl:value-of select="substring-before($string, ' ')"/>
+      <xsl:text>\ </xsl:text>
+      <xsl:call-template name="nbspace">
+       <xsl:with-param name="string" select="substring-after($string, ' ')"/>
+      </xsl:call-template>
+    </xsl:when>
+    <xsl:otherwise>
+      <xsl:value-of select="$string"/>
+    </xsl:otherwise>
+  </xsl:choose>
+</xsl:template>
+
+<!-- replaces all spaces within the funcdef/paramdef with non-breaking
+     spaces -->
+<xsl:template match="paramdef|funcdef">
+  <xsl:variable name="content">
+    <xsl:apply-templates select="*|./*|text()"/>
+  </xsl:variable>
+  <xsl:call-template name="nbspace">
+    <xsl:with-param name="string" select="$content"/>
+  </xsl:call-template>
+  <xsl:if test="local-name(.) = 'paramdef' and 
+         (following-sibling::paramdef or following-sibling::varargs)">
+    <xsl:text>, </xsl:text>
+  </xsl:if>
+</xsl:template>
+
 <xsl:template match="funcprototype">
   <xsl:variable name="funcprototype">
     <xsl:apply-templates select="funcdef"/>
   </xsl:variable>
-  <xsl:text>.sp&#10;</xsl:text>
+  <xsl:text>.HP </xsl:text>
+  <xsl:value-of select="string-length (normalize-space ($funcprototype)) - 5"/>
+  <xsl:text>&#10;</xsl:text>
   <xsl:value-of select="normalize-space ($funcprototype)"/>
-  <xsl:text> (</xsl:text>
-  <xsl:for-each select="paramdef">
-    <xsl:variable name="param">
-      <xsl:apply-templates select="." />
-    </xsl:variable>
-    <xsl:value-of select="normalize-space ($param)" />
-    <xsl:choose>
-      <xsl:when test="following-sibling::paramdef">
-       <xsl:text>,&#10;</xsl:text>
-      </xsl:when>
-      <xsl:otherwise>
-       <xsl:text>);&#10;.RE&#10;</xsl:text>
-      </xsl:otherwise>
-    </xsl:choose>
-    <xsl:if test="not (preceding-sibling::paramdef)">
-      <xsl:text>.RS </xsl:text>
-      <xsl:value-of
-       select="string-length(normalize-space ($funcprototype)) - 4" />
-      <xsl:text>&#10;</xsl:text>
-    </xsl:if>
-  </xsl:for-each>
+  <xsl:text>\ (</xsl:text>
+  <xsl:apply-templates select="void|paramdef|varargs"/>
+  <xsl:text>);&#10;</xsl:text>
 </xsl:template>
 
 </xsl:stylesheet>