franta-hg@89
|
1 |
<?xml version="1.0" encoding="UTF-8"?>
|
franta-hg@89
|
2 |
<xsl:stylesheet version="2.0"
|
franta-hg@89
|
3 |
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
|
franta-hg@89
|
4 |
xmlns:fn="http://www.w3.org/2005/xpath-functions"
|
franta-hg@89
|
5 |
xmlns:h="http://www.w3.org/1999/xhtml">
|
franta-hg@89
|
6 |
<xsl:output method="text" encoding="UTF-8"/>
|
franta-hg@89
|
7 |
<xsl:strip-space elements="*"/>
|
franta-hg@89
|
8 |
|
franta-hg@89
|
9 |
<xsl:output method="text" encoding="UTF-8"/>
|
franta-hg@89
|
10 |
<xsl:strip-space elements="*"/>
|
franta-hg@89
|
11 |
|
franta-hg@89
|
12 |
<xsl:variable name="urlBase" select="/h:html/h:head/h:base/@href"/>
|
franta-hg@91
|
13 |
|
franta-hg@89
|
14 |
|
franta-hg@89
|
15 |
<!-- Celý dokument -->
|
franta-hg@89
|
16 |
<xsl:template match="/">
|
franta-hg@89
|
17 |
<xsl:apply-templates select="h:html/h:body"/>
|
franta-hg@89
|
18 |
</xsl:template>
|
franta-hg@89
|
19 |
|
franta-hg@91
|
20 |
|
franta-hg@89
|
21 |
<xsl:template match="h:h1">
|
franta-hg@89
|
22 |
<xsl:value-of select="text()"/>
|
franta-hg@89
|
23 |
<xsl:text> </xsl:text>
|
franta-hg@92
|
24 |
<xsl:for-each select="1 to string-length(.)">=</xsl:for-each>
|
franta-hg@89
|
25 |
<xsl:text> </xsl:text>
|
franta-hg@89
|
26 |
<xsl:text> </xsl:text>
|
franta-hg@89
|
27 |
</xsl:template>
|
franta-hg@89
|
28 |
|
franta-hg@91
|
29 |
|
franta-hg@89
|
30 |
<xsl:template match="h:h2">
|
franta-hg@89
|
31 |
<xsl:value-of select="text()"/>
|
franta-hg@89
|
32 |
<xsl:text> </xsl:text>
|
franta-hg@89
|
33 |
<xsl:for-each select="1 to string-length(.)">-</xsl:for-each>
|
franta-hg@89
|
34 |
<xsl:text> </xsl:text>
|
franta-hg@89
|
35 |
<xsl:text> </xsl:text>
|
franta-hg@89
|
36 |
</xsl:template>
|
franta-hg@89
|
37 |
|
franta-hg@91
|
38 |
|
franta-hg@89
|
39 |
<xsl:template match="h:h3">
|
franta-hg@89
|
40 |
<xsl:for-each select="1 to 3">#</xsl:for-each>
|
franta-hg@89
|
41 |
<xsl:text> </xsl:text>
|
franta-hg@89
|
42 |
<xsl:value-of select="text()"/>
|
franta-hg@89
|
43 |
<xsl:text> </xsl:text>
|
franta-hg@89
|
44 |
<xsl:text> </xsl:text>
|
franta-hg@89
|
45 |
</xsl:template>
|
franta-hg@91
|
46 |
|
franta-hg@89
|
47 |
|
franta-hg@89
|
48 |
<xsl:template match="h:h4">
|
franta-hg@89
|
49 |
<xsl:for-each select="1 to 4">#</xsl:for-each>
|
franta-hg@89
|
50 |
<xsl:text> </xsl:text>
|
franta-hg@89
|
51 |
<xsl:value-of select="text()"/>
|
franta-hg@89
|
52 |
<xsl:text> </xsl:text>
|
franta-hg@89
|
53 |
<xsl:text> </xsl:text>
|
franta-hg@89
|
54 |
</xsl:template>
|
franta-hg@91
|
55 |
|
franta-hg@89
|
56 |
|
franta-hg@89
|
57 |
<xsl:template match="h:h5">
|
franta-hg@89
|
58 |
<xsl:for-each select="1 to 5">#</xsl:for-each>
|
franta-hg@89
|
59 |
<xsl:text> </xsl:text>
|
franta-hg@89
|
60 |
<xsl:value-of select="text()"/>
|
franta-hg@89
|
61 |
<xsl:text> </xsl:text>
|
franta-hg@89
|
62 |
<xsl:text> </xsl:text>
|
franta-hg@89
|
63 |
</xsl:template>
|
franta-hg@89
|
64 |
|
franta-hg@91
|
65 |
|
franta-hg@89
|
66 |
<xsl:template match="h:h6">
|
franta-hg@89
|
67 |
<xsl:for-each select="1 to 6">#</xsl:for-each>
|
franta-hg@89
|
68 |
<xsl:text> </xsl:text>
|
franta-hg@89
|
69 |
<xsl:value-of select="text()"/>
|
franta-hg@89
|
70 |
<xsl:text> </xsl:text>
|
franta-hg@89
|
71 |
<xsl:text> </xsl:text>
|
franta-hg@89
|
72 |
</xsl:template>
|
franta-hg@89
|
73 |
|
franta-hg@89
|
74 |
|
franta-hg@89
|
75 |
<xsl:template match="h:p">
|
franta-hg@89
|
76 |
<xsl:apply-templates/>
|
franta-hg@89
|
77 |
<xsl:text> </xsl:text>
|
franta-hg@89
|
78 |
<xsl:text> </xsl:text>
|
franta-hg@89
|
79 |
</xsl:template>
|
franta-hg@91
|
80 |
|
franta-hg@89
|
81 |
|
franta-hg@90
|
82 |
<xsl:template match="h:blockquote/h:p">
|
franta-hg@90
|
83 |
<xsl:text>> </xsl:text>
|
franta-hg@90
|
84 |
<xsl:apply-templates/>
|
franta-hg@90
|
85 |
<xsl:text> </xsl:text>
|
franta-hg@90
|
86 |
<xsl:text> </xsl:text>
|
franta-hg@90
|
87 |
</xsl:template>
|
franta-hg@92
|
88 |
|
franta-hg@97
|
89 |
|
franta-hg@92
|
90 |
<xsl:template match="h:cite[not(matches(., '^("|„)'))]">
|
franta-hg@92
|
91 |
<xsl:text>„</xsl:text>
|
franta-hg@92
|
92 |
<xsl:apply-templates/>
|
franta-hg@92
|
93 |
<xsl:text>“</xsl:text>
|
franta-hg@92
|
94 |
</xsl:template>
|
franta-hg@91
|
95 |
|
franta-hg@97
|
96 |
|
franta-hg@89
|
97 |
<xsl:template match="h:a">
|
franta-hg@93
|
98 |
<xsl:text>'</xsl:text>
|
franta-hg@91
|
99 |
<xsl:apply-templates select="node()"/>
|
franta-hg@93
|
100 |
<xsl:text>' <</xsl:text>
|
franta-hg@89
|
101 |
<xsl:choose>
|
franta-hg@89
|
102 |
<xsl:when test="matches(@href, '^(http:|https:|ftp:)')">
|
franta-hg@89
|
103 |
<xsl:value-of select="@href"/>
|
franta-hg@89
|
104 |
</xsl:when>
|
franta-hg@89
|
105 |
<xsl:when test="matches(@href, '^mailto:')">
|
franta-hg@89
|
106 |
<xsl:value-of select="substring-after(@href, 'mailto:')"/>
|
franta-hg@89
|
107 |
</xsl:when>
|
franta-hg@89
|
108 |
<xsl:otherwise>
|
franta-hg@89
|
109 |
<xsl:choose>
|
franta-hg@89
|
110 |
<xsl:when test="ends-with($urlBase, '/') or starts-with(@href, '/')">
|
franta-hg@89
|
111 |
<xsl:value-of select="concat($urlBase, @href)"/>
|
franta-hg@89
|
112 |
</xsl:when>
|
franta-hg@89
|
113 |
<xsl:otherwise>
|
franta-hg@89
|
114 |
<xsl:value-of select="concat($urlBase, '/', @href)"/>
|
franta-hg@89
|
115 |
</xsl:otherwise>
|
franta-hg@89
|
116 |
</xsl:choose>
|
franta-hg@89
|
117 |
</xsl:otherwise>
|
franta-hg@89
|
118 |
</xsl:choose>
|
franta-hg@89
|
119 |
<xsl:text>></xsl:text>
|
franta-hg@89
|
120 |
<xsl:if test="@title and not(matches(@title, '^\s*$'))">
|
franta-hg@89
|
121 |
<xsl:text> (</xsl:text>
|
franta-hg@89
|
122 |
<xsl:value-of select="@title"/>
|
franta-hg@89
|
123 |
<xsl:text>)</xsl:text>
|
franta-hg@89
|
124 |
</xsl:if>
|
franta-hg@89
|
125 |
</xsl:template>
|
franta-hg@89
|
126 |
|
franta-hg@91
|
127 |
|
franta-hg@89
|
128 |
<xsl:template match="h:img">
|
franta-hg@89
|
129 |
<xsl:variable name="obrázek">
|
franta-hg@89
|
130 |
<h:a href="{@src}" title="{@title}">Obrázek: <xsl:value-of select="@alt"/></h:a>
|
franta-hg@89
|
131 |
</xsl:variable>
|
franta-hg@89
|
132 |
<xsl:apply-templates select="$obrázek/node()"/>
|
franta-hg@89
|
133 |
</xsl:template>
|
franta-hg@89
|
134 |
|
franta-hg@91
|
135 |
|
franta-hg@89
|
136 |
<xsl:template match="h:strong|h:b">
|
franta-hg@89
|
137 |
<xsl:text>**</xsl:text>
|
franta-hg@89
|
138 |
<xsl:apply-templates/>
|
franta-hg@89
|
139 |
<xsl:text>**</xsl:text>
|
franta-hg@89
|
140 |
</xsl:template>
|
franta-hg@89
|
141 |
|
franta-hg@91
|
142 |
|
franta-hg@89
|
143 |
<xsl:template match="h:em|h:i">
|
franta-hg@89
|
144 |
<xsl:text>*</xsl:text>
|
franta-hg@89
|
145 |
<xsl:apply-templates/>
|
franta-hg@89
|
146 |
<xsl:text>*</xsl:text>
|
franta-hg@89
|
147 |
</xsl:template>
|
franta-hg@89
|
148 |
|
franta-hg@91
|
149 |
|
franta-hg@89
|
150 |
<xsl:template match="h:abbr[@title]">
|
franta-hg@89
|
151 |
<xsl:apply-templates/>
|
franta-hg@89
|
152 |
<xsl:text> (</xsl:text>
|
franta-hg@89
|
153 |
<xsl:value-of select="@title"/>
|
franta-hg@89
|
154 |
<xsl:text>)</xsl:text>
|
franta-hg@89
|
155 |
</xsl:template>
|
franta-hg@89
|
156 |
|
franta-hg@91
|
157 |
|
franta-hg@89
|
158 |
<xsl:template match="h:pre">
|
franta-hg@89
|
159 |
<xsl:text>--------------------------------</xsl:text>
|
franta-hg@89
|
160 |
<xsl:text> </xsl:text>
|
franta-hg@89
|
161 |
<xsl:apply-templates/>
|
franta-hg@89
|
162 |
<xsl:text> </xsl:text>
|
franta-hg@89
|
163 |
<xsl:text>--------------------------------</xsl:text>
|
franta-hg@89
|
164 |
<xsl:text> </xsl:text>
|
franta-hg@89
|
165 |
<xsl:text> </xsl:text>
|
franta-hg@89
|
166 |
</xsl:template>
|
franta-hg@89
|
167 |
|
franta-hg@91
|
168 |
|
franta-hg@89
|
169 |
<xsl:template match="h:code">
|
franta-hg@89
|
170 |
<xsl:text>`</xsl:text>
|
franta-hg@89
|
171 |
<xsl:apply-templates/>
|
franta-hg@89
|
172 |
<xsl:text>`</xsl:text>
|
franta-hg@89
|
173 |
</xsl:template>
|
franta-hg@89
|
174 |
|
franta-hg@91
|
175 |
|
franta-hg@89
|
176 |
<xsl:template match="h:hr">
|
franta-hg@89
|
177 |
<xsl:text>----------------------------------------------------------------</xsl:text>
|
franta-hg@89
|
178 |
<xsl:text> </xsl:text>
|
franta-hg@89
|
179 |
<xsl:text> </xsl:text>
|
franta-hg@89
|
180 |
</xsl:template>
|
franta-hg@89
|
181 |
|
franta-hg@91
|
182 |
|
franta-hg@96
|
183 |
<xsl:template match="h:ol|h:ul">
|
franta-hg@95
|
184 |
<xsl:variable name="úroveň" select="count(ancestor::h:li)"/>
|
franta-hg@95
|
185 |
<xsl:variable name="odsazení">
|
franta-hg@96
|
186 |
<!-- položky na nejvyšší úrovni odsazené jednou mezerou -->
|
franta-hg@96
|
187 |
<xsl:value-of select="' '"/>
|
franta-hg@96
|
188 |
<xsl:for-each select="2 to $úroveň+1">
|
franta-hg@96
|
189 |
<!-- položky na druhé a vyšší úrovni odsazené vždy dvěma dalšími mezerami -->
|
franta-hg@95
|
190 |
<xsl:value-of select="' '"/>
|
franta-hg@95
|
191 |
</xsl:for-each>
|
franta-hg@95
|
192 |
</xsl:variable>
|
franta-hg@95
|
193 |
|
franta-hg@95
|
194 |
<xsl:if test="$úroveň gt 0">
|
franta-hg@95
|
195 |
<xsl:text> </xsl:text>
|
franta-hg@95
|
196 |
</xsl:if>
|
franta-hg@95
|
197 |
|
franta-hg@89
|
198 |
<xsl:for-each select="h:li">
|
franta-hg@96
|
199 |
<xsl:if test="parent::h:ol"><xsl:value-of select="concat($odsazení, position(), ') ')"/></xsl:if>
|
franta-hg@96
|
200 |
<xsl:if test="parent::h:ul"><xsl:value-of select="concat($odsazení, '- ')"/></xsl:if>
|
franta-hg@89
|
201 |
<xsl:apply-templates/>
|
franta-hg@96
|
202 |
<xsl:if test="$úroveň = 0 or not(position() = last())">
|
franta-hg@96
|
203 |
<xsl:text> </xsl:text>
|
franta-hg@96
|
204 |
</xsl:if>
|
franta-hg@96
|
205 |
</xsl:for-each>
|
franta-hg@96
|
206 |
|
franta-hg@96
|
207 |
<xsl:if test="$úroveň = 0">
|
franta-hg@89
|
208 |
<xsl:text> </xsl:text>
|
franta-hg@96
|
209 |
</xsl:if>
|
franta-hg@89
|
210 |
</xsl:template>
|
franta-hg@89
|
211 |
|
franta-hg@89
|
212 |
|
franta-hg@89
|
213 |
<xsl:template match="text()[not(parent::h:pre)]">
|
franta-hg@89
|
214 |
<xsl:if test="matches(., '^\s')">
|
franta-hg@89
|
215 |
<xsl:text> </xsl:text>
|
franta-hg@89
|
216 |
</xsl:if>
|
franta-hg@89
|
217 |
<xsl:value-of select="normalize-space(.)"/>
|
franta-hg@89
|
218 |
<xsl:if test="matches(., '\s$')">
|
franta-hg@89
|
219 |
<xsl:text> </xsl:text>
|
franta-hg@89
|
220 |
</xsl:if>
|
franta-hg@89
|
221 |
</xsl:template>
|
franta-hg@89
|
222 |
|
franta-hg@89
|
223 |
|
franta-hg@89
|
224 |
<xsl:template match="h:div[@class='wwwLinks']">
|
franta-hg@91
|
225 |
<!--
|
franta-hg@91
|
226 |
Dvě pomlčky a mezeru budou e-maliloví klienti považovat za začátek podpisu
|
franta-hg@91
|
227 |
a zobrazí ho šedivým písmem a nebudou ho citovat v odpovědích.
|
franta-hg@91
|
228 |
-->
|
franta-hg@89
|
229 |
<xsl:text>-- </xsl:text>
|
franta-hg@89
|
230 |
<xsl:text> </xsl:text>
|
franta-hg@89
|
231 |
<xsl:apply-templates/>
|
franta-hg@89
|
232 |
</xsl:template>
|
franta-hg@89
|
233 |
|
franta-hg@89
|
234 |
|
franta-hg@89
|
235 |
</xsl:stylesheet>
|