]> granicus.if.org Git - docbook-dsssl/commitdiff
Added support for suppressing hyphenation of "computer inlines"
authorMichael Smith <xmldoc@users.sourceforge.net>
Tue, 12 Jul 2005 10:37:47 +0000 (10:37 +0000)
committerMichael Smith <xmldoc@users.sourceforge.net>
Tue, 12 Jul 2005 10:37:47 +0000 (10:37 +0000)
and filenames and URLs. More details to follow with param
checkins.

xsl/manpages/inline.xsl
xsl/manpages/links.xsl
xsl/manpages/synop.xsl
xsl/manpages/utility.xsl

index 776a96dc925866dd5e9eee77fb8d8236789a224a..7734e2d497016620b6c1ea431a5cd2506f2ed9cc 100644 (file)
 
      ******************************************************************** -->
 
+<xsl:param name="man.hyphenate.computer.inlines">0</xsl:param>
+<xsl:param name="man.hyphenate.filenames">0</xsl:param>
+<xsl:param name="man.hyphenate.urls">0</xsl:param>
+
 <!-- ==================================================================== -->
 
-<xsl:template match="filename|replaceable|varname">
+<xsl:template match="replaceable|varname">
+  <xsl:if test="$man.hyphenate.computer.inlines = 0">
+    <xsl:call-template name="suppress.hyphenation"/>
+  </xsl:if>
   <xsl:apply-templates mode="italic" select="."/>
 </xsl:template>
 
 <xsl:template match="option|userinput|envar|errorcode|constant|type">
+  <xsl:if test="$man.hyphenate.computer.inlines = 0">
+    <xsl:call-template name="suppress.hyphenation"/>
+  </xsl:if>
   <xsl:apply-templates mode="bold" select="."/>
 </xsl:template>
 
+<xsl:template match="classname">
+  <xsl:if test="$man.hyphenate.computer.inlines = 0">
+    <xsl:call-template name="suppress.hyphenation"/>
+  </xsl:if>
+  <xsl:apply-templates/>
+</xsl:template>
+
+<xsl:template match="filename">
+  <!-- * add hyphenation suppression in Filename output only if -->
+  <!-- * break.after.slash is also non-zero -->
+  <xsl:if test="$man.hyphenate.filenames = 0 and
+                $man.break.after.slash = 0">
+    <xsl:call-template name="suppress.hyphenation"/>
+  </xsl:if>
+  <xsl:apply-templates mode="italic" select="."/>
+</xsl:template>
+
 <xsl:template match="emphasis">
   <xsl:choose>
     <xsl:when test="@role = 'bold' or @role = 'strong'">
index 88d0212be1298d8d021521bc4697561c1bfe8b99..10c2bed52c217873bd8619f2526ce4221ec183b7 100644 (file)
         <xsl:apply-templates/>
       </xsl:when>
       <xsl:otherwise>
-        <!-- * the element is empty, so we just get the value of the URL; -->
+        <!-- * The element is empty, so we just get the value of the URL; -->
         <!-- * note that we don't number empty links -->
+        <!-- * -->
+        <!-- * Add hyphenation suppression in URL output only if -->
+        <!-- * break.after.slash is also non-zero -->
+        <xsl:if test="$man.hyphenate.urls = 0 and
+                      $man.break.after.slash = 0">
+          <xsl:call-template name="suppress.hyphenation"/>
+          <xsl:text>\%</xsl:text>
+        </xsl:if>
         <xsl:value-of select="$url"/>
       </xsl:otherwise>
     </xsl:choose>
     <!-- * formatting could be made user-configurable - something -->
     <!-- * other than square brackets. But what else would work? -->
     <!-- * <10> Angle brackets? {10} Braces? -->
-    <xsl:text>[</xsl:text> 
+    <xsl:text>[</xsl:text>
     <xsl:value-of select="$link.number"/>
-    <xsl:text>]</xsl:text>
+    <xsl:text>]\&amp;</xsl:text>
+    <!-- * Note that the reason for the \& after the closing bracket -->
+    <!-- * is to prevent a hyphen character from being rendered -->
+    <!-- * between the closing bracket and the following text - even -->
+    <!-- * when the following text is preceded by a "hyphenation -->
+    <!-- * character"; for example: -->
+    <!-- * -->
+    <!-- *  [26]\&\fI\%COUNTRY\fR\fR -->
+    <!-- * -->
+    <!-- * Where COUNTRY is marked up with as <envar>COUNTRY</envar> -->
+    <!-- * in the source (we generate \% before all Envar output (and -->
+    <!-- * all other "computer inlines") to prevent it from being -->
+    <!-- * broken across lines. -->
+    <!-- * -->
+    <!-- * Without the \& after the closing bracket, if the -->
+    <!-- * [26]\fI\%COUNTRY\fR\fR instance fell at the end of a line, -->
+    <!-- * a hyphen could end up being inserted; for example: -->
+    <!-- * -->
+    <!-- *   if you are uncertain, check the value of the [26]- -->
+    <!-- *   COUNTRY environment variable -->
+    <!-- * -->
+    <!-- * The \& causes [26]COUNTRY to be treated as a unit, -->
+    <!-- * preventing insertion of the stray hyphen. -->
   </xsl:if>
   <xsl:choose>
     <!-- * if user wants links underlined, underline (ital) it -->
     <xsl:text>&#10;</xsl:text>
     <xsl:text>.br&#10;</xsl:text>
     <!-- * Print the link's URL -->
+    <!-- * Add hyphenation suppression in URL output only if -->
+    <!-- * break.after.slash is also non-zero -->
+    <xsl:if test="$man.hyphenate.urls = 0 and
+                  $man.break.after.slash = 0">
+      <xsl:call-template name="suppress.hyphenation"/>
+      <xsl:text>\%</xsl:text>
+    </xsl:if>
     <xsl:value-of select="@url"/>
     <xsl:text>&#10;</xsl:text>
   </xsl:for-each>
index 92e59bfd07f66a2fffced272db71ae05409a62bb..edd1210eb1e680568c3ba9df8fa00a6e7f81e9fe 100644 (file)
 </xsl:template>
 
 <xsl:template match="command">
+  <xsl:call-template name="suppress.hyphenation"/>
   <xsl:apply-templates mode="bold" select="."/>
 </xsl:template>
 
 <xsl:template match="function[not(ancestor::command)]">
+  <xsl:call-template name="suppress.hyphenation"/>
   <xsl:apply-templates mode="bold" select="."/>
 </xsl:template>
 
 <xsl:template match="parameter[not(ancestor::command)]">
+  <xsl:call-template name="suppress.hyphenation"/>
   <xsl:apply-templates mode="italic" select="."/>
 </xsl:template>
 
index 1a2613be5c50c74122d82a558034266f556fb138..3d5dd6559ba8f6e7dc6e6d35640c63ae7cba97c2 100644 (file)
 
   <!-- ================================================================== -->
 
+  <xsl:template name="suppress.hyphenation">
+    <!-- * we need to suppress hyphenation inline only if hyphenation is -->
+    <!-- * actually on, and even then only outside of Cmdsynopsis and -->
+    <!-- * Funcsynopsis, where it is already always turned off -->
+    <xsl:if test="$man.hyphenate != 0 and
+                  not(ancestor::cmdsynopsis) and
+                  not(ancestor::funcsynopsis)">
+      <xsl:text>\%</xsl:text>
+    </xsl:if>
+  </xsl:template>
+
+  <!-- ================================================================== -->
+
   <!-- * The nested-section-title template is called for refsect3, and any -->
   <!-- * refsection nested more than 2 levels deep, and for formalpara. -->
   <xsl:template name="nested-section-title">