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                exclude-result-prefixes="exsl">
6
7<xsl:import href="http://docbook.sourceforge.net/release/xsl/current/manpages/docbook.xsl"/>
8<xsl:import href="stylesheet-common.xsl" />
9
10
11<!-- Parameters -->
12
13<xsl:param name="man.authors.section.enabled">0</xsl:param>
14<xsl:param name="man.copyright.section.enabled">0</xsl:param>
15<xsl:param name="man.output.base.dir"></xsl:param>
16<xsl:param name="man.output.in.separate.dir" select="1"></xsl:param>
17<xsl:param name="refentry.meta.get.quietly" select="0"></xsl:param>
18<xsl:param name="man.th.title.max.length">32</xsl:param> <!-- enough room for "CREATE TEXT SEARCH CONFIGURATION" -->
19<xsl:param name="man.th.extra3.max.length">40</xsl:param> <!-- enough room for "PostgreSQL X.Ydevel Documentation" -->
20<xsl:param name="refentry.xref.manvolnum" select="1"/> <!-- overridden from stylesheet-common.xsl -->
21
22<!-- Fixup for apostrophe groff output.  See the following references:
23     <http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=457839>
24     <https://sourceforge.net/tracker/?func=detail&aid=2412738&group_id=21935&atid=373747>
25 -->
26<xsl:param name="man.string.subst.map.local.post">
27  <substitution oldstring="\'" newstring="\(aq"></substitution>
28</xsl:param>
29
30
31<!-- Custom templates -->
32
33<!-- Improve output of email element.  See also
34     <https://sourceforge.net/tracker/?func=detail&aid=3524417&group_id=21935&atid=373747>
35 -->
36<xsl:template match="email">
37  <xsl:text>&lt;</xsl:text>
38  <xsl:apply-templates/>
39  <xsl:text>&gt;</xsl:text>
40</xsl:template>
41
42
43<!-- Make superscripts visible in man pages (default is no decoration) -->
44<xsl:template match="superscript">
45  <xsl:text>^</xsl:text>
46  <xsl:apply-templates/>
47</xsl:template>
48
49
50<xsl:template match="refentry" mode="xref-to">
51  <xsl:param name="referrer"/>
52  <xsl:param name="xrefstyle"/>
53
54  <xsl:choose>
55    <!-- If the refname contains a space, we construct a reference
56         like CREATE DATABASE (CREATE_DATABASE(7)), so the reader
57         knows both the command name being referred to and the name of
58         the man page to read about it. -->
59    <xsl:when test="contains(refnamediv/refname[1],' ')">
60      <xsl:variable name="mangled.title">
61        <xsl:value-of select="translate(refnamediv/refname[1],' ','_')"/>
62      </xsl:variable>
63      <xsl:apply-templates select="refnamediv/refname[1]"/>
64      <xsl:text> (</xsl:text>
65      <xsl:call-template name="bold">
66        <xsl:with-param name="node" select="exsl:node-set($mangled.title)"/>
67        <xsl:with-param name="context" select="."/>
68      </xsl:call-template>
69      <xsl:apply-templates select="refmeta/manvolnum"/>
70      <xsl:text>)</xsl:text>
71    </xsl:when>
72
73    <!-- This is the original case, except that boldness has been
74         added, per the convention mentioned in man-pages(7). -->
75    <xsl:otherwise>
76      <xsl:choose>
77        <xsl:when test="refmeta/refentrytitle">
78          <xsl:call-template name="bold">
79            <xsl:with-param name="node" select="refmeta/refentrytitle"/>
80            <xsl:with-param name="context" select="."/>
81          </xsl:call-template>
82        </xsl:when>
83        <xsl:otherwise>
84          <xsl:call-template name="bold">
85            <xsl:with-param name="node" select="refnamediv/refname[1]"/>
86            <xsl:with-param name="context" select="."/>
87          </xsl:call-template>
88        </xsl:otherwise>
89      </xsl:choose>
90      <xsl:apply-templates select="refmeta/manvolnum"/>
91    </xsl:otherwise>
92  </xsl:choose>
93
94</xsl:template>
95
96
97<!-- For refentries we don't man to generate a man page for, leave out
98     manvolnum, let it default to 0, and skip writing out man files
99     with section 0. -->
100
101<!-- overridden from common/refentry.xsl -->
102<xsl:template name="get.refentry.section">
103  <xsl:choose>
104    <xsl:when test="refmeta/manvolnum">
105      <xsl:value-of select="refmeta/manvolnum"/>
106    </xsl:when>
107    <xsl:otherwise>
108      <xsl:text>0</xsl:text>
109    </xsl:otherwise>
110  </xsl:choose>
111</xsl:template>
112
113<!-- overridden from manpages/other.xsl -->
114  <xsl:template name="write.man.file">
115    <xsl:param name="name"/>
116    <xsl:param name="section"/>
117    <xsl:param name="lang"/>
118    <xsl:param name="content"/>
119    <xsl:param name="filename">
120      <xsl:call-template name="make.adjusted.man.filename">
121        <xsl:with-param name="name" select="$name"/>
122        <xsl:with-param name="section" select="$section"/>
123        <xsl:with-param name="lang" select="$lang"/>
124      </xsl:call-template>
125    </xsl:param>
126    <xsl:if test="$section != 0">
127    <xsl:call-template name="write.text.chunk">
128      <xsl:with-param name="filename" select="$filename"/>
129      <xsl:with-param name="suppress-context-node-name" select="1"/>
130      <xsl:with-param name="quiet" select="$man.output.quietly"/>
131      <xsl:with-param
132          name="message-prolog"
133          >Note: </xsl:with-param>
134      <xsl:with-param name="encoding" select="$man.output.encoding"/>
135      <xsl:with-param name="content" select="$content"/>
136    </xsl:call-template>
137    </xsl:if>
138  </xsl:template>
139
140
141<!-- Overridden template as workaround for this problem:
142     <https://sourceforge.net/tracker/?func=detail&aid=2831602&group_id=21935&atid=373747>
143-->
144  <xsl:template name="write.stubs">
145    <xsl:param name="first.refname"/>
146    <xsl:param name="section"/>
147    <xsl:param name="lang"/>
148    <xsl:for-each select="refnamediv/refname">
149      <xsl:if test=". != $first.refname">
150        <xsl:call-template name="write.text.chunk">
151          <xsl:with-param name="filename">
152            <xsl:call-template name="make.adjusted.man.filename">
153              <xsl:with-param name="name" select="."/>
154              <xsl:with-param name="section" select="$section"/>
155              <xsl:with-param name="lang" select="$lang"/>
156            </xsl:call-template>
157          </xsl:with-param>
158          <xsl:with-param name="quiet" select="$man.output.quietly"/>
159          <xsl:with-param name="suppress-context-node-name" select="1"/>
160          <xsl:with-param name="message-prolog">Note: </xsl:with-param>
161          <xsl:with-param name="message-epilog"> (soelim stub)</xsl:with-param>
162          <xsl:with-param name="content">
163            <xsl:choose>
164              <xsl:when test="$man.output.in.separate.dir = 0">
165                <xsl:value-of select="concat('.so man', $section, '/')"/>
166              </xsl:when>
167              <xsl:otherwise>
168                <xsl:value-of select="'.so '"/> <!-- added case -->
169              </xsl:otherwise>
170            </xsl:choose>
171            <xsl:call-template name="make.adjusted.man.filename">
172              <xsl:with-param name="name" select="$first.refname"/>
173              <xsl:with-param name="section" select="$section"/>
174            </xsl:call-template>
175            <xsl:text>&#10;</xsl:text>
176          </xsl:with-param>
177        </xsl:call-template>
178      </xsl:if>
179    </xsl:for-each>
180  </xsl:template>
181
182
183  <!-- https://sourceforge.net/tracker/?func=detail&aid=3545150&group_id=21935&atid=373747 -->
184  <xsl:template match="step/title">
185    <xsl:apply-templates/>
186    <xsl:text>: </xsl:text>
187  </xsl:template>
188
189
190  <!-- http://sourceforge.net/p/docbook/bugs/1340/ -->
191  <xsl:template match="indexterm"/>
192
193
194<!-- https://github.com/docbook/xslt10-stylesheets/issues/59 -->
195<xsl:template match="a/sup">
196  <xsl:apply-templates/>
197</xsl:template>
198
199
200<!-- Gentext customization -->
201
202<!-- see http://www.sagehill.net/docbookxsl/CustomGentext.html -->
203<xsl:param name="local.l10n.xml" select="document('')"/>
204<l:i18n xmlns:l="http://docbook.sourceforge.net/xmlns/l10n/1.0">
205  <l:l10n language="en">
206    <!-- Use ISO 8601 date format. -->
207    <l:context name="datetime">
208      <l:template name="format" text="Y-m-d"/>
209    </l:context>
210
211    <!-- Slight rephrasing to indicate that missing sections are found
212         in the documentation. -->
213    <l:context name="xref-number-and-title">
214      <l:template name="chapter" text="Chapter %n, %t, in the documentation"/>
215      <l:template name="sect1" text="Section %n, “%t”, in the documentation"/>
216      <l:template name="sect2" text="Section %n, “%t”, in the documentation"/>
217      <l:template name="sect3" text="Section %n, “%t”, in the documentation"/>
218      <l:template name="sect4" text="Section %n, “%t”, in the documentation"/>
219      <l:template name="sect5" text="Section %n, “%t”, in the documentation"/>
220    </l:context>
221  </l:l10n>
222</l:i18n>
223
224</xsl:stylesheet>
225