summaryrefslogtreecommitdiffstats
path: root/kdoctools/docbook/xsl/manpages/lists.xsl
blob: 5e956d4dc7a1b8a7a76698a41804a296cfb67946 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
<?xml version='1.0'?>
<!-- vim:set sts=2 shiftwidth=2 syntax=sgml: -->
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
                version='1.0'>

<xsl:template match="para[ancestor::listitem or ancestor::step]|
	             simpara[ancestor::listitem or ancestor::step]|
		     remark[ancestor::listitem or ancestor::step]">
  <xsl:for-each select="node()">
    <xsl:choose>
      <xsl:when test="self::literallayout|self::screen|self::programlisting|
		      self::itemizedlist|self::orderedlist|self::variablelist|
		      self::simplelist">
        <xsl:text>&#10;</xsl:text>
        <xsl:apply-templates select="."/>
      </xsl:when>
      <xsl:when test="self::text()">
	<xsl:if test="starts-with(translate(.,'&#10;',' '), ' ') and
		      preceding-sibling::node()[name(.)!='']">
	  <xsl:text> </xsl:text>
	</xsl:if>
        <xsl:variable name="content">
	  <xsl:apply-templates select="."/>
	</xsl:variable>
	<xsl:value-of select="normalize-space($content)"/>
	<xsl:if
        test="translate(substring(., string-length(.), 1),'&#10;',' ') = ' '
	      and following-sibling::node()[name(.)!='']">
	  <xsl:text> </xsl:text>
	</xsl:if>
      </xsl:when>
      <xsl:otherwise>
        <xsl:variable name="content">
          <xsl:apply-templates select="."/>
        </xsl:variable>
        <xsl:value-of select="normalize-space($content)"/>
      </xsl:otherwise>
    </xsl:choose>
  </xsl:for-each>
  <xsl:text>&#10;</xsl:text>

  <xsl:if test="following-sibling::para or
	  following-sibling::simpara or
	  following-sibling::remark">
    <!-- Make sure multiple paragraphs within a list item don't -->
    <!-- merge together.                                        -->
    <xsl:text>&#10;</xsl:text>
  </xsl:if>
</xsl:template>

<xsl:template match="varlistentry|glossentry">
  <xsl:text>&#10;.TP&#10;</xsl:text>
  <xsl:apply-templates/>
</xsl:template>

<xsl:template match="variablelist[ancestor::listitem or ancestor::step]|
	             glosslist[ancestor::listitem or ancestor::step]">
  <xsl:text>&#10;.RS&#10;</xsl:text>
  <xsl:apply-templates/>
  <xsl:text>&#10;.RE&#10;.IP&#10;</xsl:text>
</xsl:template>

<xsl:template match="varlistentry/term|glossterm">
  <xsl:variable name="content">
    <xsl:apply-templates/>
  </xsl:variable>
  <xsl:value-of select="normalize-space($content)"/>
  <xsl:text>, </xsl:text>
</xsl:template>

<xsl:template
     match="varlistentry/term[position()=last()]|glossterm[position()=last()]"
     priority="2">
  <xsl:variable name="content">
    <xsl:apply-templates/>
  </xsl:variable>
  <xsl:value-of select="normalize-space($content)"/>
</xsl:template>

<xsl:template match="varlistentry/listitem|glossdef">
  <xsl:text>&#10;</xsl:text>
  <xsl:apply-templates/>
</xsl:template>

<xsl:template match="itemizedlist/listitem">
  <xsl:text>\(bu&#10;</xsl:text>
  <xsl:apply-templates/>
  <xsl:if test="following-sibling::listitem">
    <xsl:text>.TP&#10;</xsl:text>
  </xsl:if>
</xsl:template>

<xsl:template match="orderedlist/listitem|procedure/step">
  <xsl:number format="1."/>
  <xsl:text>&#10;</xsl:text>
  <xsl:apply-templates/>
  <xsl:if test="position()!=last()">
    <xsl:text>.TP&#10;</xsl:text>
  </xsl:if>
</xsl:template>

<xsl:template match="itemizedlist|orderedlist|procedure">
  <xsl:text>&#10;.TP 3&#10;</xsl:text>
  <xsl:apply-templates/>
  <xsl:text>.LP&#10;</xsl:text>
</xsl:template>

<xsl:template match="itemizedlist[ancestor::listitem or ancestor::step]|
	             orderedlist[ancestor::listitem or ancestor::step]|
		     procedure[ancestor::listitem or ancestor::step]">
  <xsl:text>&#10;.RS&#10;.TP 3&#10;</xsl:text>
  <xsl:apply-templates/>
  <xsl:text>.LP&#10;.RE&#10;.IP&#10;</xsl:text>
</xsl:template>

<!-- simplelist -->

<xsl:template match="simplelist[@type='inline']">
  <xsl:apply-templates/>
</xsl:template>

<xsl:template match="simplelist[@type='inline']/member">
  <xsl:apply-templates/>
  <xsl:text>, </xsl:text>
</xsl:template>

<xsl:template match="simplelist[@type='inline']/member[position()=last()]"
	      priority="2">
  <xsl:apply-templates/>
</xsl:template>

<xsl:template match="simplelist[@type='vert' and @columns='1']">
  <xsl:text>&#10;.IP&#10;</xsl:text>
  <xsl:apply-templates/>
  <xsl:text>.LP&#10;</xsl:text>
</xsl:template>

<xsl:template match="simplelist[@type='vert' and @columns='1']/member">
  <xsl:apply-templates/>
  <xsl:text>&#10;&#10;</xsl:text>
</xsl:template>

</xsl:stylesheet>