forked from NixOS/nixos-homepage
-
Notifications
You must be signed in to change notification settings - Fork 0
/
bootstrapify-docbook.xsl
121 lines (99 loc) · 3.96 KB
/
bootstrapify-docbook.xsl
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
<?xml version="1.0"?>
<xsl:stylesheet
version="1.0"
xmlns="http://www.w3.org/1999/xhtml"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:x="http://www.w3.org/1999/xhtml"
exclude-result-prefixes="x">
<xsl:output method="html" omit-xml-declaration="yes" indent="no"/>
<xsl:template match="/">
<xsl:apply-templates select="/x:html/x:body/x:div[@class!='navheader' and @class!='navfooter']" mode="top" />
</xsl:template>
<xsl:template match="*" mode="top">
<div class="page-header">
<xsl:if test="@class='book'">
<h1><xsl:apply-templates select="//x:div[@class='book']/x:div[@class='titlepage']//x:h1/node()"/></h1>
<h2><xsl:apply-templates select="//x:div[@class='book']/x:div[@class='titlepage']//x:h2/node()"/></h2>
</xsl:if>
<xsl:if test="@class!='book'">
<h1>NixOS Manual</h1>
</xsl:if>
</div>
<xsl:if test="//x:link/@rel">
<ul class="pager">
<xsl:if test="@class='book'">
<xsl:attribute name="class">hidden</xsl:attribute>
</xsl:if>
<xsl:if test="@class!='book'">
<xsl:attribute name="class">pager</xsl:attribute>
</xsl:if>
<xsl:if test="//x:link[@rel='prev']">
<li class="previous">
<a accesskey="p"><xsl:attribute name="href"><xsl:value-of select="//x:link[@rel='prev']/@href"/></xsl:attribute>
← <xsl:value-of select="//x:link[@rel='prev']/@title" /></a>
</li>
</xsl:if>
<xsl:if test="//x:link[@rel='up']">
<li class="up">
<a accesskey="u"><xsl:attribute name="href"><xsl:value-of select="//x:link[@rel='up']/@href"/></xsl:attribute>
↑ <xsl:value-of select="//x:link[@rel='up']/@title" /></a>
</li>
</xsl:if>
<xsl:if test="//x:link[@rel='next']">
<li class="next">
<a accesskey="n"><xsl:attribute name="href"><xsl:value-of select="//x:link[@rel='next']/@href"/></xsl:attribute>
<xsl:value-of select="//x:link[@rel='next']/@title" /> →</a>
</li>
</xsl:if>
</ul>
</xsl:if>
<div class="docbook">
<xsl:apply-templates />
</div>
</xsl:template>
<xsl:template match="@*|node()">
<xsl:copy>
<xsl:apply-templates select="@*|node()" />
</xsl:copy>
</xsl:template>
<!--
<xsl:template match="x:div[@class='chapter' or @class='appendix']//x:div[@class='toc']" />
-->
<xsl:template match="x:div[@class='list-of-examples' or @class='author']" />
<xsl:template match="x:p[@class='copyright']" />
<xsl:template match="x:p[@class='copyright']" />
<xsl:template match="x:div[@class='preface' or @class='chapter' or @class='section' or @class='appendix']">
<section>
<xsl:apply-templates select="@*|node()" />
</section>
</xsl:template>
<xsl:template match="x:h1">
<div class='page-header'><h1><xsl:apply-templates select="@*|node()" /></h1></div>
</xsl:template>
<!--
<xsl:template match="x:h2">
<div class='page-header'><h2><xsl:apply-templates select="@*|node()" /></h2></div>
</xsl:template>
-->
<xsl:template match="x:div[@class='titlepage' and ../@class = 'book']" />
<xsl:template match="x:div[@class='warning' and count(x:p) = 1]" priority='1'>
<div class="alert alert-warning">
<strong>Warning:</strong><xsl:text> </xsl:text><xsl:apply-templates select="x:p/node()" />
</div>
</xsl:template>
<xsl:template match="x:div[@class='warning']">
<div class="alert alert-warning">
<xsl:apply-templates select="node()[not(self::x:h3)]" />
</div>
</xsl:template>
<xsl:template match="x:div[@class='note' and count(x:p) = 1]" priority='1'>
<div class="alert alert-info">
<strong>Note:</strong><xsl:text> </xsl:text><xsl:apply-templates select="x:p/node()" />
</div>
</xsl:template>
<xsl:template match="x:table">
<table class='table table-striped'>
<xsl:apply-templates select="@*|node()" />
</table>
</xsl:template>
</xsl:stylesheet>