]> granicus.if.org Git - docbook-dsssl/commitdiff
Initial checkin of some changes related to making PS/PDF output
authorMichael Smith <xmldoc@users.sourceforge.net>
Tue, 26 Feb 2008 09:55:32 +0000 (09:55 +0000)
committerMichael Smith <xmldoc@users.sourceforge.net>
Tue, 26 Feb 2008 09:55:32 +0000 (09:55 +0000)
from "man -l -Tps" look better. The current changes:

  - render synopsis and verbatim sections in a monospace/code font

  - put a light-grey background behind all programlisting, screen,
    and literallayout instances

  - prevent SH heads in PS output from being rendered in uppercase
    (as they are in console output)

  - also display xrefs to SH heads in PS output in normal case
    (instead of uppercase)

  - draw a line under SH heads in PS output

The changes made to the code to support the above features were:

  - added some embedded/custom macros: one for conditionally
    upper-casing SH x-refs, one for redefining the SH macro
    itself, with some conditional handling for PS output, and
    finally a macro for putting a background/screen (filled box)
    around a block of text (e.g., a program listing) in PS output

  - added utility templates for wrapping blocks of text in code
    font; also templates for inline code font

xsl/manpages/other.xsl
xsl/manpages/utility.xsl

index df41b804b326bdaf5114d275a1ac92ed42942d0b..034a6df0b50bb395ab311e401e8df33c14c4b998 100644 (file)
@@ -669,4 +669,98 @@ db:manvolnum
     </xsl:if>
   </xsl:template>
 
+  <!-- ============================================================== -->
+
+  <xsl:template name="define.macros">
+    <xsl:text>.\" define a macro for condtionally upper-casing SH x-refs&#10;</xsl:text>
+    <xsl:text>.de SH-xref
+.ie n \{\
+.tr aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZ
+\\$*
+.tr aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz
+.\}
+.el \{\
+\\$*
+.\}
+..&#10;</xsl:text>
+    <xsl:text>.\" define a level-one heading that works better for non-TTY output&#10;</xsl:text>
+    <xsl:text>.de1 SH
+.sp 1
+.sp \\n[PD]u
+.nr an-level 1
+.set-an-margin
+.nr an-prevailing-indent \\n[IN]
+.fi
+.in \\n[an-margin]u
+.ti 0
+.HTML-TAG ".NH \\n[an-level]"
+.it 1 an-trap
+.nr an-no-space-flag 1
+.nr an-break-flag 1
+.ps +3
+.ft B
+.ne (2v + 1u)
+.\" if we have only one arg, just use that
+.ie (\\n[.$] == 1) \{\
+.ie n \{\
+\&amp;\\$1
+.\}
+.el \{\
+.nr an-break-flag 0
+.\" if this is troff/non-TTY output, show the second arg only
+\&amp;\\$1
+.in \\n[an-margin]u
+.ti 0
+.\" draw a border/line under subheading
+.sp -.7
+\l'\n(.lu'
+.\}
+.\}
+.\" we have more that one arg, so we decide which to use
+.el \{\
+.ie n \{\
+.if \\n[.$] \&amp;\\$1
+.\" if this is nroff/TTY output, show the first arg only
+.\}
+.el \{\
+.nr an-break-flag 0
+.\" if this is troff/non-TTY output, show the second arg only
+.if \\n[.$] \&amp;\\$2
+.in \\n[an-margin]u
+.ti 0
+.\" draw a border/line under subheading
+.sp -.7
+\l'\n(.lu'
+.\}
+.\}
+..&#10;</xsl:text>
+    <xsl:text>\" define BB/BE macros for putting a background/screen&#10;</xsl:text>
+    <xsl:text>\" (filled box) around a block of text in non-TTY output&#10;</xsl:text>
+    <xsl:text>.de BB
+.br
+.in +2n
+.ll -2n
+.gcolor red
+.di BX
+..
+.de EB
+.br
+.di
+.in
+.ll
+.gcolor
+.nr BW \\n(.lu-\\n(.i
+.nr BH \\n(dn+.5v
+.ne \\n(BHu+.5v
+\M[lightgray]\h'1n'\v'-.5v'\D'P \\n(BWu 0 0 \\n(BHu -\\n(BWu 0 0 -\\n(BHu'\M[]
+.in 0
+.sp -.5v
+.nf
+.BX
+.in
+.sp .5v
+.fi
+..&#10;</xsl:text>
+</xsl:template>
+
 </xsl:stylesheet>
index 93a75d3ab217dce54788ec35fb62aec85c0a3b3d..d3ba029ad5c3dcbb6f05b64bf5418f96d7d90900 100644 (file)
 
   <!-- ================================================================== -->
 
+  <xsl:template name="verbatim-block-start">
+    <xsl:call-template name="store-current-font-family"/>
+    <xsl:text>.fam C&#10;</xsl:text>
+  </xsl:template>
+
+  <xsl:template name="verbatim-block-end">
+    <xsl:text>.fam \*(ZX&#10;</xsl:text>
+  </xsl:template>
+
+  <xsl:template name="code-inline-start">
+    <xsl:text>\FC</xsl:text>
+  </xsl:template>
+
+  <xsl:template name="code-inline-end">
+    <xsl:text>\F[\*(ZX]</xsl:text>
+  </xsl:template>
+
+  <xsl:template name="store-current-font-family">
+    <xsl:text>.ds ZX \n[.fam]&#10;</xsl:text>
+  </xsl:template>
+
+  <!-- ================================================================== -->
+
   <!-- * NOTE TO DEVELOPERS: For ease of maintenance, the current -->
   <!-- * manpages stylesheets use the mode="prevent.line.breaking" -->
   <!-- * templates for anything and everything that needs to have -->
       <xsl:with-param name="replacement" select="'_'"/>
     </xsl:call-template>
   </xsl:template>
-  
+
   <!-- ================================================================== -->
 
+  <xsl:template name="make.subheading">
+    <xsl:param name="title"/>
+    <xsl:call-template name="mark.subheading"/>
+    <xsl:text>.SH</xsl:text>
+    <xsl:text> </xsl:text>
+    <xsl:value-of select="$title"/>
+    <xsl:text>&#10;</xsl:text>
+    <xsl:call-template name="mark.subheading"/>
+  </xsl:template>
+
+  <xsl:template name="make.title.pair">
+    <xsl:param name="title"/>
+    <!-- * Use uppercase to render first version of title. -->
+    <xsl:text>"</xsl:text>
+    <xsl:call-template name="string.upper">
+      <xsl:with-param name="string">
+        <xsl:value-of select="normalize-space($title)"/>
+      </xsl:with-param>
+    </xsl:call-template>
+    <xsl:text>"</xsl:text>
+    <!-- * end of uppercase title -->
+    <xsl:text> </xsl:text>
+    <!-- * Use lowercase to render second version of title. -->
+    <xsl:text>"</xsl:text>
+    <xsl:value-of select="normalize-space($title)"/>
+    <xsl:text>"</xsl:text>
+    <!-- * end of lowercase title -->
+  </xsl:template>
+
   <!-- * Put a horizontal rule or other divider around section titles -->
   <!-- * in roff source (just to make things easier to read). -->
   <xsl:template name="mark.subheading">
     </xsl:if>
   </xsl:template>
 
+  <!-- ================================================================== -->
+
+  <xsl:template name="roff-if-else-start">
+    <xsl:param name="condition">n</xsl:param>
+    <xsl:text>.ie </xsl:text>
+    <xsl:value-of select="$condition"/>
+    <xsl:text> \{\&#10;</xsl:text>
+  </xsl:template>
+
+  <xsl:template name="roff-if-start">
+    <xsl:param name="condition">n</xsl:param>
+    <xsl:text>.if </xsl:text>
+    <xsl:value-of select="$condition"/>
+    <xsl:text> \{\&#10;</xsl:text>
+  </xsl:template>
+
+  <xsl:template name="roff-else">
+    <xsl:text>.\}&#10;</xsl:text>
+    <xsl:text>.el \{\&#10;</xsl:text>
+  </xsl:template>
+
+  <xsl:template name="roff-if-end">
+    <xsl:text>.\}&#10;</xsl:text>
+  </xsl:template>
+
 </xsl:stylesheet>