]> granicus.if.org Git - docbook-dsssl/commitdiff
Problem::
authorMichael Smith <xmldoc@users.sourceforge.net>
Wed, 5 Oct 2005 07:00:57 +0000 (07:00 +0000)
committerMichael Smith <xmldoc@users.sourceforge.net>
Wed, 5 Oct 2005 07:00:57 +0000 (07:00 +0000)
Number generated for Synopfragref output, but no number generated
in Synopfragment output.

Cause::
manpages stylesheets import the HTML stylesheets. manpages
stylesheets do not include a Synopfragref template, so they were
just picking up the HTML one. However, the manpages stylesheet
did have a Synopfragment template, which overrode the HTML one.
Problem is that the manpages Synopfragment was not complete.

Fix::
Correctly "ported" Synopfragment template from HTML stylesheets
and added manpages-specific character markup and features. As a
result of these changes, in the output now:

  - correct numbers a generated for Synopfragment output

  - Synopfragref contentes are italicized, as they should be

  - Synopfragment output is output with a hanging indent (similar
    to the hanging indent used for Cmysynopsis output)

  - for cases where there are a group of Synopfragments together,
    a line of vertical space is generated only before first, and
    suppressed before subsequent ones.

Closes #599439. Thanks to Dennis Grace for reporting the problem
(long, long ago) and for submitting a patch (which was used as-is
but neverthelesss provided some insights).

xsl/manpages/synop.xsl

index af8943597f734417b4585aa4c5e93c5d28054ac1..fb2e15c77340e0d1808c7e33f4d2572ae37d6b53 100644 (file)
 <!-- * find any code here for handling it. It is a _verbatim_ -->
 <!-- * environment; check the block.xsl file instead. -->
 
+<xsl:template match="synopfragmentref">
+  <xsl:variable name="target" select="key('id',@linkend)"/>
+  <xsl:variable name="snum">
+    <xsl:apply-templates select="$target" mode="synopfragment.number"/>
+  </xsl:variable>
+  <xsl:text>(</xsl:text>
+  <xsl:value-of select="$snum"/>
+  <xsl:text>)</xsl:text>
+  <xsl:text>&#160;</xsl:text>
+  <xsl:variable name="synopfragmentref">
+    <FragRefContents><xsl:value-of select="normalize-space(.)"/></FragRefContents>
+  </xsl:variable>
+  <xsl:apply-templates select="exsl:node-set($synopfragmentref)" mode="italic"/>
+</xsl:template>
+
+<xsl:template match="synopfragment" mode="synopfragment.number">
+  <xsl:number format="1"/>
+</xsl:template>
+
 <xsl:template match="synopfragment">
-  <xsl:text>.PP&#10;</xsl:text>
+  <xsl:variable name="snum">
+    <xsl:apply-templates select="." mode="synopfragment.number"/>
+  </xsl:variable>
+  <xsl:text>&#10;</xsl:text>
+  <!-- * If we have a group of Synopgfragments, we only want to output a -->
+  <!-- * line of space before the first; so when we find a Synopfragment -->
+  <!-- * whose first preceding sibling is another Synopfragment, we back -->
+  <!-- * up one line vertically to negate the line of vertical space -->
+  <!-- * that's added by the .HP macro -->
+  <xsl:if test="preceding-sibling::*[1][self::synopfragment]">
+    <xsl:text>.sp -1&#10;</xsl:text>
+  </xsl:if>
+  <xsl:text>.HP </xsl:text>
+  <!-- * For each Synopfragment, make a hanging paragraph, with the -->
+  <!-- * indent calculated from the length of the generated number -->
+  <!-- * used as a reference + pluse 3 characters (for the open and -->
+  <!-- * close parens around the number, plus a space). -->
+  <xsl:value-of select="string-length (normalize-space ($snum)) + 3"/>
+  <xsl:text>&#10;</xsl:text>
+  <xsl:text>(</xsl:text>
+  <xsl:value-of select="$snum"/>
+  <xsl:text>)</xsl:text>
+  <xsl:text> </xsl:text>
   <xsl:apply-templates/>
 </xsl:template>