inline.xsl 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219
  1. <?xml version='1.0'?>
  2. <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  3. xmlns:exsl="http://exslt.org/common"
  4. version='1.0'>
  5. <!-- ********************************************************************
  6. $Id: inline.xsl 7897 2008-03-10 15:46:03Z xmldoc $
  7. ********************************************************************
  8. This file is part of the XSL DocBook Stylesheet distribution.
  9. See ../README or http://docbook.sf.net/release/xsl/current/ for
  10. copyright and other information.
  11. ******************************************************************** -->
  12. <!-- ==================================================================== -->
  13. <xsl:template match="replaceable|varname|structfield">
  14. <xsl:if test="$man.hyphenate.computer.inlines = 0">
  15. <xsl:call-template name="suppress.hyphenation"/>
  16. </xsl:if>
  17. <xsl:call-template name="italic">
  18. <xsl:with-param name="node" select="."/>
  19. <xsl:with-param name="context" select="."/>
  20. </xsl:call-template>
  21. </xsl:template>
  22. <xsl:template match="option|userinput|envar|errorcode|constant|markup">
  23. <xsl:if test="$man.hyphenate.computer.inlines = 0">
  24. <xsl:call-template name="suppress.hyphenation"/>
  25. </xsl:if>
  26. <xsl:call-template name="bold">
  27. <xsl:with-param name="node" select="."/>
  28. <xsl:with-param name="context" select="."/>
  29. </xsl:call-template>
  30. </xsl:template>
  31. <xsl:template match="classname">
  32. <xsl:if test="$man.hyphenate.computer.inlines = 0">
  33. <xsl:call-template name="suppress.hyphenation"/>
  34. </xsl:if>
  35. <xsl:apply-templates/>
  36. </xsl:template>
  37. <xsl:template match="command">
  38. <xsl:if test="$man.hyphenate.computer.inlines = 0">
  39. <xsl:call-template name="suppress.hyphenation"/>
  40. </xsl:if>
  41. <xsl:call-template name="bold">
  42. <xsl:with-param name="node" select="."/>
  43. <xsl:with-param name="context" select="."/>
  44. </xsl:call-template>
  45. </xsl:template>
  46. <xsl:template match="type[not(ancestor::cmdsynopsis) and
  47. not(ancestor::funcsynopsis)]">
  48. <xsl:if test="$man.hyphenate.computer.inlines = 0">
  49. <xsl:call-template name="suppress.hyphenation"/>
  50. </xsl:if>
  51. <xsl:call-template name="bold">
  52. <xsl:with-param name="node" select="."/>
  53. <xsl:with-param name="context" select="."/>
  54. </xsl:call-template>
  55. </xsl:template>
  56. <xsl:template match="function[not(ancestor::cmdsynopsis) and
  57. not(ancestor::funcsynopsis)]">
  58. <xsl:if test="$man.hyphenate.computer.inlines = 0">
  59. <xsl:call-template name="suppress.hyphenation"/>
  60. </xsl:if>
  61. <xsl:call-template name="bold">
  62. <xsl:with-param name="node" select="."/>
  63. <xsl:with-param name="context" select="."/>
  64. </xsl:call-template>
  65. </xsl:template>
  66. <xsl:template match="parameter[not(ancestor::cmdsynopsis) and
  67. not(ancestor::funcsynopsis)]">
  68. <xsl:if test="$man.hyphenate.computer.inlines = 0">
  69. <xsl:call-template name="suppress.hyphenation"/>
  70. </xsl:if>
  71. <xsl:call-template name="italic">
  72. <xsl:with-param name="node" select="."/>
  73. <xsl:with-param name="context" select="."/>
  74. </xsl:call-template>
  75. </xsl:template>
  76. <xsl:template match="filename">
  77. <!-- * add hyphenation suppression in Filename output only if -->
  78. <!-- * break.after.slash is also non-zero -->
  79. <xsl:if test="$man.hyphenate.filenames = 0 and
  80. $man.break.after.slash = 0">
  81. <xsl:call-template name="suppress.hyphenation"/>
  82. </xsl:if>
  83. <!-- * part of the old man(7) man page, now man-pages(7), says, -->
  84. <!-- * "Filenames (whether pathnames, or references to files in the -->
  85. <!-- * /usr/include directory) are always in italics". But that's dumb, -->
  86. <!-- * and looks like crap in PS/printed/PDF output, and there's no -->
  87. <!-- * sound rationale for it, so we don't do it. -->
  88. <xsl:call-template name="inline.monoseq"/>
  89. </xsl:template>
  90. <xsl:template match="emphasis">
  91. <xsl:choose>
  92. <xsl:when test="
  93. @role = 'bold' or
  94. @role = 'strong' or
  95. @remap = 'B'">
  96. <xsl:call-template name="bold">
  97. <xsl:with-param name="node" select="."/>
  98. <xsl:with-param name="context" select="."/>
  99. </xsl:call-template>
  100. </xsl:when>
  101. <xsl:otherwise>
  102. <xsl:call-template name="italic">
  103. <xsl:with-param name="node" select="."/>
  104. <xsl:with-param name="context" select="."/>
  105. </xsl:call-template>
  106. </xsl:otherwise>
  107. </xsl:choose>
  108. </xsl:template>
  109. <xsl:template match="optional">
  110. <xsl:value-of select="$arg.choice.opt.open.str"/>
  111. <xsl:apply-templates/>
  112. <xsl:value-of select="$arg.choice.opt.close.str"/>
  113. </xsl:template>
  114. <xsl:template name="do-citerefentry">
  115. <xsl:param name="refentrytitle" select="''"/>
  116. <xsl:param name="manvolnum" select="''"/>
  117. <xsl:variable name="title">
  118. <xsl:value-of select="$refentrytitle"/>
  119. </xsl:variable>
  120. <xsl:call-template name="bold">
  121. <xsl:with-param name="node" select="exsl:node-set($title)"/>
  122. <xsl:with-param name="context" select="."/>
  123. </xsl:call-template>
  124. <xsl:text>(</xsl:text>
  125. <xsl:value-of select="$manvolnum"/>
  126. <xsl:text>)</xsl:text>
  127. </xsl:template>
  128. <xsl:template match="citerefentry">
  129. <xsl:call-template name="do-citerefentry">
  130. <xsl:with-param name="refentrytitle" select="refentrytitle"/>
  131. <xsl:with-param name="manvolnum" select="manvolnum"/>
  132. </xsl:call-template>
  133. </xsl:template>
  134. <xsl:template match="trademark|productname">
  135. <xsl:apply-templates/>
  136. <xsl:choose>
  137. <!-- * Just use true Unicode chars for copyright, trademark, etc., -->
  138. <!-- * symbols (by default, we later automatically translate them -->
  139. <!-- * with the apply-string-subst-map template, or with the -->
  140. <!-- * default character map, if man.charmap.enabled is true). -->
  141. <xsl:when test="@class = 'copyright'">
  142. <xsl:text>&#x00a9;</xsl:text>
  143. </xsl:when>
  144. <xsl:when test="@class = 'registered'">
  145. <xsl:text>&#x00ae;</xsl:text>
  146. </xsl:when>
  147. <xsl:when test="@class = 'service'">
  148. <xsl:text>&#x2120;</xsl:text>
  149. </xsl:when>
  150. <xsl:when test="@class = 'trade'">
  151. <xsl:text>&#x2122;</xsl:text>
  152. </xsl:when>
  153. <!-- * for Trademark element, render a trademark symbol by default -->
  154. <!-- * even if no "class" value is specified -->
  155. <xsl:when test="self::trademark" >
  156. <xsl:text>&#x2122;</xsl:text>
  157. </xsl:when>
  158. <xsl:otherwise>
  159. <!-- * otherwise we have a Productname with no value for the -->
  160. <!-- * "class" attribute, so don't render any symbol by default -->
  161. </xsl:otherwise>
  162. </xsl:choose>
  163. </xsl:template>
  164. <!-- * span seems to sneak through into output sometimes, possibly due -->
  165. <!-- * to failed Olink processing; so we need to catch it -->
  166. <xsl:template match="span">
  167. <xsl:apply-templates/>
  168. </xsl:template>
  169. <xsl:template match="inlinemediaobject">
  170. <xsl:apply-templates/>
  171. </xsl:template>
  172. <!-- * indexterm instances produce groff comments like this: -->
  173. <!-- * .\" primary: secondary: tertiary -->
  174. <xsl:template match="indexterm">
  175. <xsl:text>.\" </xsl:text>
  176. <xsl:apply-templates/>
  177. <xsl:text>&#10;</xsl:text>
  178. </xsl:template>
  179. <xsl:template match="primary">
  180. <xsl:value-of select="normalize-space(.)"/>
  181. </xsl:template>
  182. <xsl:template match="secondary|tertiary">
  183. <xsl:text>: </xsl:text>
  184. <xsl:value-of select="normalize-space(.)"/>
  185. </xsl:template>
  186. <!-- * non-empty remark instances produce groff comments -->
  187. <xsl:template match="remark">
  188. <xsl:variable name="content" select="normalize-space(.)"/>
  189. <xsl:if test="not($content = '')">
  190. <xsl:text>.\" </xsl:text>
  191. <xsl:value-of select="$content"/>
  192. <xsl:text>&#10;</xsl:text>
  193. </xsl:if>
  194. </xsl:template>
  195. </xsl:stylesheet>