]> git.donarmstrong.com Git - dactyl.git/blob - common/content/help.xsl
Import 1.0b7.1 supporting Firefox up to 8.*
[dactyl.git] / common / content / help.xsl
1 <?xml version="1.0" encoding="utf-8"?>
2 <!DOCTYPE stylesheet SYSTEM "dactyl://content/dtd">
3
4 <!-- Header {{{1 -->
5 <xsl:stylesheet version="1.0"
6     xmlns="http://www.w3.org/1999/xhtml"
7     xmlns:html="http://www.w3.org/1999/xhtml"
8     xmlns:dactyl="http://vimperator.org/namespaces/liberator"
9     xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
10     xmlns:exsl="http://exslt.org/common"
11     xmlns:regexp="http://exslt.org/regular-expressions"
12     xmlns:str="http://exslt.org/strings"
13     extension-element-prefixes="exsl regexp str">
14
15     <xsl:output method="xml" indent="no"/>
16
17     <!-- Variable Definitions {{{1 -->
18
19
20     <!-- Process Overlays {{{1 -->
21
22     <xsl:template name="splice-overlays">
23         <xsl:param name="elem"/>
24         <xsl:param name="tag"/>
25         <xsl:for-each select="ancestor::*/dactyl:overlay/*[@insertbefore=$tag]">
26             <xsl:apply-templates select="." mode="overlay"/>
27         </xsl:for-each>
28         <xsl:choose>
29             <xsl:when test="ancestor::*/dactyl:overlay/*[@replace=$tag] and not($elem[@replace])">
30                 <xsl:for-each select="ancestor::*/dactyl:overlay/*[@replace=$tag]">
31                     <xsl:apply-templates select="." mode="overlay-2"/>
32                 </xsl:for-each>
33             </xsl:when>
34             <xsl:otherwise>
35                 <xsl:for-each select="$elem">
36                     <xsl:apply-templates select="." mode="overlay-2"/>
37                 </xsl:for-each>
38             </xsl:otherwise>
39         </xsl:choose>
40         <xsl:for-each select="ancestor::*/dactyl:overlay/*[@insertafter=$tag]">
41             <xsl:apply-templates select="." mode="overlay"/>
42         </xsl:for-each>
43     </xsl:template>
44
45     <xsl:template match="dactyl:tags[parent::dactyl:document]|dactyl:tag" mode="overlay">
46         <xsl:call-template name="splice-overlays">
47             <xsl:with-param name="tag" select="substring-before(concat(., ' '), ' ')"/>
48             <xsl:with-param name="elem" select="self::node()"/>
49         </xsl:call-template>
50     </xsl:template>
51     <xsl:template match="*[dactyl:tags]" mode="overlay">
52         <xsl:call-template name="splice-overlays">
53             <xsl:with-param name="tag" select="substring-before(concat(dactyl:tags, ' '), ' ')"/>
54             <xsl:with-param name="elem" select="self::node()"/>
55         </xsl:call-template>
56     </xsl:template>
57     <xsl:template match="dactyl:*[@tag and not(@replace)]" mode="overlay">
58         <xsl:call-template name="splice-overlays">
59             <xsl:with-param name="tag" select="substring-before(concat(@tag, ' '), ' ')"/>
60             <xsl:with-param name="elem" select="self::node()"/>
61         </xsl:call-template>
62     </xsl:template>
63
64     <!-- Process Inclusions {{{1 -->
65
66     <xsl:template name="include">
67         <xsl:param name="root-node" select="."/>
68         <xsl:param name="overlay" select="concat('dactyl://help-overlay/', $root-node/@name)"/>
69
70         <!-- Ridiculous three-pass processing is needed to deal with
71            - lack of dynamic variable scope in XSL 1.0.  -->
72
73         <!-- Store a copy of the overlay for the current document. -->
74         <xsl:variable name="doc">
75             <dactyl:document>
76                 <xsl:copy-of select="document($overlay)/dactyl:overlay"/>
77                 <xsl:copy-of select="$root-node/node()"/>
78             </dactyl:document>
79         </xsl:variable>
80
81         <xsl:call-template name="parse-tags">
82             <xsl:with-param name="text" select="concat($root-node/@name, '.xml')"/>
83         </xsl:call-template>
84         <xsl:apply-templates select="exsl:node-set($doc)/dactyl:document/node()[position() != 1]" mode="overlay"/>
85     </xsl:template>
86
87     <xsl:template match="dactyl:include" mode="overlay-2">
88         <div dactyl:highlight="HelpInclude">
89             <xsl:call-template name="include">
90                 <xsl:with-param name="root-node" select="document(@href)/dactyl:document"/>
91             </xsl:call-template>
92         </div>
93     </xsl:template>
94
95     <xsl:template match="@*|node()" mode="overlay">
96         <xsl:apply-templates select="." mode="overlay-2"/>
97     </xsl:template>
98     <xsl:template match="@*|node()" mode="overlay-2">
99         <xsl:copy>
100             <xsl:apply-templates select="@*|node()" mode="overlay"/>
101         </xsl:copy>
102     </xsl:template>
103
104     <!-- Root {{{1 -->
105
106     <xsl:template match="/">
107
108         <!-- Ridiculous three-pass processing is needed to deal with
109            - lack of dynamic variable scope in XSL 1.0.  -->
110
111         <xsl:variable name="doc1">
112             <xsl:call-template name="include">
113                 <xsl:with-param name="root-node" select="dactyl:document"/>
114             </xsl:call-template>
115         </xsl:variable>
116         <xsl:variable name="root" select="exsl:node-set($doc1)"/>
117
118         <!-- Store a cache of all tags defined -->
119         <xsl:variable name="doc2">
120             <dactyl:document>
121                 <xsl:attribute name="document-tags">
122                     <xsl:text> </xsl:text>
123                     <xsl:for-each select="$root//@tag|$root//dactyl:tags/text()|$root//dactyl:tag/text()">
124                         <xsl:value-of select="concat(., ' ')"/>
125                     </xsl:for-each>
126                 </xsl:attribute>
127                 <xsl:copy-of select="$root/node()"/>
128             </dactyl:document>
129         </xsl:variable>
130         <xsl:variable name="root2" select="exsl:node-set($doc2)/dactyl:document"/>
131
132         <html dactyl:highlight="Help">
133             <head>
134                 <title><xsl:value-of select="/dactyl:document/@title"/></title>
135                 <script type="text/javascript" src="resource://dactyl-content/help.js"/>
136             </head>
137             <body dactyl:highlight="HelpBody">
138                 <xsl:apply-templates select="$root2/node()|$root2/@*" mode="help-1"/>
139             </body>
140         </html>
141     </xsl:template>
142
143     <!-- Table of Contents {{{1 -->
144
145     <xsl:template name="toc">
146         <xsl:param name="level" select="1"/>
147         <xsl:param name="context"/>
148         <xsl:param name="toc"/>
149
150         <xsl:variable name="tag" select="concat('h', $level)"/>
151         <xsl:variable name="lasttag" select="concat('h', $level - 1)"/>
152
153         <xsl:variable name="nodes" select="$toc/*[
154             local-name() = $tag and not(preceding::*[local-name() = $lasttag][position() = 1 and not(.=$context)])]"/>
155
156         <xsl:if test="$nodes">
157             <ol level="{$level}" dactyl:highlight="HelpOrderedList">
158                 <xsl:for-each select="$nodes">
159                     <li>
160                         <a>
161                             <xsl:if test="@tag">
162                                 <xsl:attribute name="href"><xsl:value-of select="concat('#', substring-before(concat(@tag, ' '), ' '))"/></xsl:attribute>
163                             </xsl:if>
164                             <xsl:apply-templates select="node()[not(self::dactyl:strut)]" mode="help-1"/>
165                         </a>
166                         <xsl:call-template name="toc">
167                             <xsl:with-param name="level" select="$level + 1"/>
168                             <xsl:with-param name="context" select="."/>
169                             <xsl:with-param name="toc" select="$toc"/>
170                         </xsl:call-template>
171                     </li>
172                 </xsl:for-each>
173             </ol>
174         </xsl:if>
175     </xsl:template>
176     <xsl:template match="dactyl:toc" mode="help-2">
177         <xsl:variable name="TOC">
178             <context/>
179             <xsl:for-each
180                 select="following::dactyl:h1|following::dactyl:h2|following::dactyl:h3|following::dactyl:h4|following::dactyl:h5">
181                 <xsl:copy-of select="."/>
182             </xsl:for-each>
183         </xsl:variable>
184         <xsl:variable name="toc" select="exsl:node-set($TOC)"/>
185
186         <xsl:if test="//dactyl:toc[1 and self::*]">
187             <div dactyl:highlight="HelpTOC">
188                 <h2><!--L-->Contents</h2>
189                 <xsl:if test="@start">
190                     <xsl:call-template name="toc">
191                         <xsl:with-param name="level" select="number(@start)"/>
192                         <xsl:with-param name="toc" select="$toc"/>
193                     </xsl:call-template>
194                 </xsl:if>
195                 <xsl:if test="not(@start)">
196                     <xsl:call-template name="toc">
197                         <xsl:with-param name="toc" select="$toc"/>
198                     </xsl:call-template>
199                 </xsl:if>
200             </div>
201         </xsl:if>
202     </xsl:template>
203
204     <!-- Items {{{1 -->
205
206     <xsl:template match="dactyl:strut" mode="help-2">
207         <div style="clear: both"/>
208     </xsl:template>
209     <xsl:template match="dactyl:item" mode="help-2">
210         <div dactyl:highlight="HelpItem">
211             <xsl:apply-templates select="dactyl:tags|dactyl:spec|dactyl:strut" mode="help-1"/>
212             <xsl:if test="not(dactyl:description/@short)">
213                 <hr style="border: 0; height: 0; margin: 0; width: 100%; float: right;"/>
214                 <xsl:if test="dactyl:type|dactyl:default">
215                     <div dactyl:highlight="HelpOptInfo">
216                         <xsl:apply-templates select="dactyl:type|dactyl:default" mode="help-1"/>
217                         <div style="clear: both;"/>
218                     </div>
219                 </xsl:if>
220             </xsl:if>
221             <xsl:apply-templates select="dactyl:description" mode="help-1"/>
222             <div style="clear: both;"/>
223         </div>
224     </xsl:template>
225     <!--
226     <xsl:template match="dactyl:item/dactyl:spec[position() = last()]" mode="help-2">
227         <div style="clear: both;"/>
228         <div dactyl:highlight="HelpSpec"><xsl:apply-templates mode="help-1"/></div>
229     </xsl:template>
230     -->
231
232     <xsl:template match="dactyl:default[not(@type='plain')]" mode="help-2">
233         <xsl:variable name="type" select="preceding-sibling::dactyl:type[1] | following-sibling::dactyl:type[1]"/>
234         <span dactyl:highlight="HelpDefault">
235             <xsl:copy-of select="@*"/>
236             <xsl:text>(default: </xsl:text>
237             <xsl:choose>
238                 <xsl:when test="$type = 'string'">
239                     <span dactyl:highlight="HelpString" delim="'"><xsl:apply-templates mode="help-1"/></span>
240                 </xsl:when>
241                 <xsl:when test="contains($type, 'list') or contains($type, 'map')">
242                     <span dactyl:highlight="HelpString" delim=""><xsl:apply-templates mode="help-1"/></span>
243                     <xsl:if test=". = ''"><!--L-->(empty)</xsl:if>
244                 </xsl:when>
245                 <xsl:otherwise>
246                     <span>
247                         <xsl:attribute name="dactyl:highlight">
248                             <xsl:choose>
249                                 <xsl:when test="$type = 'boolean'">Boolean</xsl:when>
250                                 <xsl:when test="$type = 'number'">Number</xsl:when>
251                                 <xsl:when test="$type = 'charlist'">String</xsl:when>
252                             </xsl:choose>
253                         </xsl:attribute>
254                         <xsl:apply-templates select="node()" mode="help-1"/>
255                     </span>
256                 </xsl:otherwise>
257             </xsl:choose>)</span>
258     </xsl:template>
259
260     <!-- Tag Definitions {{{1 -->
261
262     <xsl:template match="dactyl:item/dactyl:tags[position() = last()]" mode="help-2">
263         <div style="clear: right"/>
264         <xsl:call-template name="parse-tags">
265             <xsl:with-param name="text" select="."/>
266         </xsl:call-template>
267     </xsl:template>
268     <xsl:template match="dactyl:tags" mode="help-2">
269         <xsl:call-template name="parse-tags">
270             <xsl:with-param name="text" select="."/>
271         </xsl:call-template>
272     </xsl:template>
273     <xsl:template match="@tag[parent::dactyl:p]" mode="help-2">
274         <xsl:call-template name="parse-tags">
275             <xsl:with-param name="text" select="."/>
276         </xsl:call-template>
277         <div style="clear: right"/>
278     </xsl:template>
279     <xsl:template match="dactyl:tag|@tag" mode="help-2">
280         <xsl:call-template name="parse-tags">
281             <xsl:with-param name="text" select="."/>
282         </xsl:call-template>
283     </xsl:template>
284     <xsl:template name="parse-tags">
285         <xsl:param name="text"/>
286         <div dactyl:highlight="HelpTags">
287         <xsl:for-each select="str:tokenize($text)">
288             <a id="{.}" dactyl:highlight="HelpTag"><xsl:value-of select="."/></a>
289         </xsl:for-each>
290         </div>
291     </xsl:template>
292
293     <!-- Tag Links {{{1 -->
294
295     <xsl:template name="linkify-tag">
296         <xsl:param name="contents" select="text()"/>
297         <xsl:variable name="tag" select="$contents"/>
298         <a style="color: inherit;">
299             <xsl:if test="not(@link) or @link != 'false'">
300                 <xsl:choose>
301                     <xsl:when test="contains(ancestor::*/@document-tags, concat(' ', $tag, ' '))">
302                         <xsl:attribute name="href">#<xsl:value-of select="$tag"/></xsl:attribute>
303                     </xsl:when>
304                     <xsl:otherwise>
305                         <xsl:attribute name="href">dactyl://help-tag/<xsl:value-of select="$tag"/></xsl:attribute>
306                     </xsl:otherwise>
307                 </xsl:choose>
308             </xsl:if>
309             <xsl:value-of select="$contents"/>
310         </a>
311     </xsl:template>
312
313     <xsl:template match="dactyl:o" mode="help-2">
314         <span dactyl:highlight="HelpOpt">
315             <xsl:call-template name="linkify-tag">
316                 <xsl:with-param name="contents" select='concat("&#39;", text(), "&#39;")'/>
317             </xsl:call-template>
318         </span>
319     </xsl:template>
320     <xsl:template match="dactyl:pref" mode="help-2">
321         <a href="http://kb.mozillazine.org/{text()}" dactyl:highlight="HelpOpt"
322             >'<xsl:apply-templates select="@*|node()" mode="help-1"/>'</a>
323     </xsl:template>
324     <xsl:template match="dactyl:t" mode="help-2">
325         <span dactyl:highlight="HelpTopic">
326             <xsl:call-template name="linkify-tag"/>
327         </span>
328     </xsl:template>
329     <xsl:template match="dactyl:k" mode="help-2">
330         <span dactyl:highlight="HelpKey">
331             <xsl:call-template name="linkify-tag"/>
332         </span>
333     </xsl:template>
334     <xsl:template match="dactyl:kwd" mode="help-2">
335         <span dactyl:highlight="HelpKeyword">
336             <xsl:apply-templates select="@*|node()" mode="help-1"/>
337         </span>
338     </xsl:template>
339     <xsl:template match="dactyl:k[@name]" mode="help-2">
340         <span dactyl:highlight="HelpKey">
341             <xsl:call-template name="linkify-tag">
342                 <xsl:with-param name="contents" select="concat('&lt;', @name, '>', .)"/>
343             </xsl:call-template>
344         </span>
345     </xsl:template>
346     <xsl:template match="dactyl:k[@mode]" mode="help-2">
347         <span dactyl:highlight="HelpKey">
348             <xsl:call-template name="linkify-tag">
349                 <xsl:with-param name="contents" select="concat(@mode, '_', text())"/>
350             </xsl:call-template>
351         </span>
352     </xsl:template>
353     <xsl:template match="dactyl:k[@mode and @name]" mode="help-2">
354         <span dactyl:highlight="HelpKey">
355             <xsl:call-template name="linkify-tag">
356                 <xsl:with-param name="contents" select="concat(@mode, '_', '&lt;', @name, '>', .)"/>
357             </xsl:call-template>
358         </span>
359     </xsl:template>
360
361     <!-- HTML-ish elements {{{1 -->
362
363     <xsl:template match="dactyl:dl" mode="help-2">
364         <xsl:apply-templates select="@tag" mode="help-1"/>
365         <dl>
366             <column style="{@dt}"/>
367             <column style="{@dd}"/>
368             <xsl:for-each select="dactyl:dt">
369                 <tr>
370                     <xsl:apply-templates select="." mode="help-1"/>
371                     <xsl:apply-templates select="following-sibling::dactyl:dd[1]" mode="help-1"/>
372                 </tr>
373             </xsl:for-each>
374         </dl>
375     </xsl:template>
376
377     <xsl:template match="dactyl:link" mode="help-2">
378         <a>
379             <xsl:choose>
380                 <xsl:when test="not(@topic)"/>
381                 <xsl:when test="regexp:match(@topic, '^([a-zA-Z]+:|[^/]*#|/)', '')">
382                     <xsl:attribute name="href"><xsl:value-of select="@topic"/></xsl:attribute>
383                 </xsl:when>
384                 <xsl:otherwise>
385                     <xsl:attribute name="href"><xsl:value-of select="concat('dactyl://help-tag/', @topic)"/></xsl:attribute>
386                 </xsl:otherwise>
387             </xsl:choose>
388             <xsl:if test="regexp:match(@topic, '^[a-zA-Z]+:', '')
389                     and not(starts-with(@topic, 'mailto:') or
390                             starts-with(@topic, 'chrome:') or
391                             starts-with(@topic, 'resource:') or
392                             starts-with(@topic, 'dactyl:'))">
393                     <!-- A regexp does not work for the second test here â†‘. :( -->
394                 <xsl:attribute name="rel">external</xsl:attribute>
395             </xsl:if>
396             <xsl:apply-templates select="@*|node()" mode="help-1"/>
397         </a>
398     </xsl:template>
399
400     <xsl:template match="dactyl:hl" mode="help-2">
401         <span dactyl:highlight="{@key}"><xsl:apply-templates select="@*|node()" mode="help-1"/></span>
402     </xsl:template>
403     <xsl:template match="dactyl:h" mode="help-2">
404         <em><xsl:apply-templates select="@*|node()" mode="help-1"/></em>
405     </xsl:template>
406     <xsl:template match="dactyl:em | dactyl:tt | dactyl:p  |
407                          dactyl:dt | dactyl:dd |
408                          dactyl:ol | dactyl:ul | dactyl:li |
409                          dactyl:h1 | dactyl:h2 | dactyl:h3 |
410                          dactyl:h4"
411                   mode="help-2">
412         <xsl:element name="{local-name()}">
413             <xsl:apply-templates select="@*|node()" mode="help-1"/>
414         </xsl:element>
415     </xsl:template>
416
417     <xsl:template match="dactyl:code" mode="help-2">
418         <pre dactyl:highlight="HelpCode"><xsl:apply-templates select="@*|node()" mode="help-1"/></pre>
419     </xsl:template>
420
421     <!-- Help elements {{{1 -->
422
423     <xsl:template match="dactyl:a" mode="help-2">
424         <span dactyl:highlight="HelpArg">{<xsl:apply-templates select="@*|node()" mode="help-1"/>}</span>
425     </xsl:template>
426     <xsl:template match="dactyl:oa" mode="help-2">
427         <span dactyl:highlight="HelpOptionalArg">[<xsl:apply-templates select="@*|node()" mode="help-1"/>]</span>
428     </xsl:template>
429
430     <xsl:template match="dactyl:deprecated" mode="help-2">
431         <p style="clear: both;">
432             <xsl:apply-templates select="@*" mode="help-1"/>
433             <span dactyl:highlight="HelpWarning"><!--L-->Deprecated:</span>
434             <xsl:text> </xsl:text>
435             <xsl:apply-templates select="node()" mode="help-1"/>
436         </p>
437     </xsl:template>
438     <xsl:template match="dactyl:note" mode="help-2">
439         <p style="clear: both;">
440             <xsl:apply-templates select="@*" mode="help-1"/>
441             <div style="clear: both;"/>
442             <span dactyl:highlight="HelpNote"><!--L-->Note:</span>
443             <xsl:text> </xsl:text>
444             <xsl:apply-templates select="node()" mode="help-1"/>
445         </p>
446     </xsl:template>
447     <xsl:template match="dactyl:warning" mode="help-2">
448         <p style="clear: both;">
449             <xsl:apply-templates select="@*" mode="help-1"/>
450             <div style="clear: both;"/>
451             <span dactyl:highlight="HelpWarning"><!--L-->Warning:</span>
452             <xsl:text> </xsl:text>
453             <xsl:apply-templates select="node()" mode="help-1"/>
454         </p>
455     </xsl:template>
456     <xsl:template match="dactyl:default" mode="help-2">
457         <span dactyl:highlight="HelpDefault">(default:<xsl:text> </xsl:text><xsl:apply-templates select="@*|node()" mode="help-1"/>)</span>
458     </xsl:template>
459
460     <!-- HTML-ify other elements {{{1 -->
461
462     <xsl:template match="dactyl:ex" mode="help-2">
463         <span dactyl:highlight="HelpEx">
464             <xsl:variable name="tag" select="str:tokenize(text(), ' [!')[1]"/>
465             <a href="dactyl://help-tag/{$tag}" style="color: inherit;">
466                 <xsl:if test="contains(ancestor::*/@document-tags, concat(' ', $tag, ' '))">
467                     <xsl:attribute name="href">#<xsl:value-of select="$tag"/></xsl:attribute>
468                 </xsl:if>
469                 <xsl:apply-templates mode="help-1"/>
470             </a>
471         </span>
472     </xsl:template>
473
474     <xsl:template match="dactyl:se" mode="help-2">
475         <xsl:variable name="nodes" xmlns="&xmlns.dactyl;">
476             <html:span style="display: inline-block;">
477                 <ex>:set</ex>
478                 <xsl:text> </xsl:text>
479                 <link>
480                     <xsl:if test="@link != 'false'">
481                         <xsl:attribute name="topic">'<xsl:value-of select="@opt"/>'</xsl:attribute>
482                     </xsl:if>
483                     <hl key="HelpOpt"><xsl:value-of select="@opt"/></hl>
484                 </link>
485                 <xsl:choose>
486                     <xsl:when test="@op and @op != ''"><xsl:value-of select="@op"/></xsl:when>
487                     <xsl:otherwise>=</xsl:otherwise>
488                 </xsl:choose>
489                 <xsl:copy-of select="@*|node()"/>
490             </html:span>
491         </xsl:variable>
492         <xsl:apply-templates select="exsl:node-set($nodes)" mode="help-1"/>
493     </xsl:template>
494
495     <xsl:template match="dactyl:set" mode="help-2">
496         <xsl:variable name="nodes">
497             <code xmlns="&xmlns.dactyl;">
498                 <se opt="{@opt}" op="{@op}" link="{@link}">
499                     <xsl:copy-of select="@*|node()"/>
500                 </se>
501             </code>
502         </xsl:variable>
503         <xsl:apply-templates select="exsl:node-set($nodes)" mode="help-1"/>
504     </xsl:template>
505
506     <xsl:template match="dactyl:description | dactyl:example | dactyl:spec" mode="help-2">
507         <div>
508             <xsl:if test="self::dactyl:description"><xsl:attribute name="dactyl:highlight">HelpDescription</xsl:attribute></xsl:if>
509             <xsl:if test="self::dactyl:example"><xsl:attribute name="dactyl:highlight">HelpExample</xsl:attribute></xsl:if>
510             <xsl:if test="self::dactyl:spec"><xsl:attribute name="dactyl:highlight">HelpSpec</xsl:attribute></xsl:if>
511             <xsl:apply-templates select="@*|node()" mode="help-1"/>
512         </div>
513     </xsl:template>
514     <xsl:template match="dactyl:type" mode="help-2">
515         <a dactyl:highlight="HelpType">
516             <xsl:choose>
517                 <xsl:when test="contains(ancestor::*/@document-tags, concat(' ', ., ' '))">
518                     <xsl:attribute name="href">#<xsl:value-of select="."/></xsl:attribute>
519                 </xsl:when>
520                 <xsl:when test="not(. = 'boolean' or . = 'number' or . = 'string')">
521                     <xsl:attribute name="href">dactyl://help-tag/<xsl:value-of select="."/></xsl:attribute>
522                 </xsl:when>
523             </xsl:choose>
524             <xsl:apply-templates select="@*|node()" mode="help-1"/>
525         </a>
526     </xsl:template>
527     <xsl:template match="dactyl:str" mode="help-2">
528         <span dactyl:highlight="HelpString">
529             <xsl:apply-templates select="@*|node()" mode="help-1"/>
530         </span>
531     </xsl:template>
532     <xsl:template match="dactyl:xml-block" mode="help-2">
533         <div dactyl:highlight="HelpXMLBlock">
534             <xsl:call-template name="xml-highlight"/>
535         </div>
536     </xsl:template>
537     <xsl:template match="dactyl:xml-highlight" mode="help-2">
538         <xsl:call-template name="xml-highlight"/>
539     </xsl:template>
540
541     <!-- Plugins {{{1 -->
542
543     <xsl:template name="info">
544         <xsl:param name="label"/>
545         <xsl:param name="link" select="@href"/>
546         <xsl:param name="nodes" select="node()"/>
547         <xsl:param name="extra"/>
548         <div dactyl:highlight="HelpInfo">
549             <div dactyl:highlight="HelpInfoLabel">
550                 <xsl:value-of select="$label"/>:
551             </div>
552             <span dactyl:highlight="HelpInfoValue">
553                 <a>
554                     <xsl:if test="$link">
555                         <xsl:attribute name="href"><xsl:value-of select="$link"/></xsl:attribute>
556                     </xsl:if>
557                     <xsl:copy-of select="exsl:node-set($nodes)"/>
558                 </a>
559                 <xsl:copy-of select="exsl:node-set($extra)"/>
560             </span>
561         </div>
562     </xsl:template>
563     <xsl:template match="dactyl:author[@email]" mode="help-2">
564         <xsl:call-template name="info">
565             <xsl:with-param name="label" select="'Author'"/>
566             <xsl:with-param name="extra">
567                 <xsl:text> </xsl:text><a href="mailto:{@email}"></a>
568             </xsl:with-param>
569         </xsl:call-template>
570     </xsl:template>
571     <xsl:template match="dactyl:author" mode="help-2">
572         <xsl:call-template name="info">
573             <xsl:with-param name="label" select="'Author'"/>
574         </xsl:call-template>
575     </xsl:template>
576     <xsl:template match="dactyl:license" mode="help-2">
577         <xsl:call-template name="info">
578             <xsl:with-param name="label" select="'License'"/>
579         </xsl:call-template>
580     </xsl:template>
581     <xsl:template match="dactyl:plugin" mode="help-2">
582         <xsl:call-template name="info">
583             <xsl:with-param name="label" select="'Plugin'"/>
584             <xsl:with-param name="nodes">
585                 <span><xsl:value-of select="@name"/></span>
586             </xsl:with-param>
587         </xsl:call-template>
588         <xsl:if test="@version">
589             <xsl:call-template name="info">
590                 <xsl:with-param name="label" select="'Version'"/>
591                 <xsl:with-param name="link" select="''"/>
592                 <xsl:with-param name="nodes">
593                     <span><xsl:value-of select="@version"/></span>
594                 </xsl:with-param>
595             </xsl:call-template>
596         </xsl:if>
597         <xsl:apply-templates mode="help-1"/>
598     </xsl:template>
599
600     <!-- Special Element Templates {{{1 -->
601
602     <xsl:template match="dactyl:logo" mode="help-1">
603         <span dactyl:highlight="Logo"/>
604     </xsl:template>
605
606     <!-- Process Tree {{{1 -->
607
608     <xsl:template match="@*|node()" mode="help-2">
609         <xsl:copy>
610             <xsl:apply-templates select="@*|node()" mode="help-1"/>
611         </xsl:copy>
612     </xsl:template>
613     <xsl:template match="@*|node()" mode="help-1">
614         <xsl:apply-templates select="." mode="help-2"/>
615     </xsl:template>
616
617     <!-- XML Highlighting (xsl:import doesn't work in Firefox 3.x) {{{1 -->
618     <xsl:template name="xml-highlight">
619         <div dactyl:highlight="HelpXML">
620             <xsl:apply-templates mode="xml-highlight"/>
621         </div>
622     </xsl:template>
623
624     <xsl:template name="xml-namespace">
625         <xsl:param name="node" select="."/>
626         <xsl:if test="name($node) != local-name($node)">
627             <span dactyl:highlight="HelpXMLNamespace">
628                 <xsl:value-of select="substring-before(name($node), ':')"/>
629             </span>
630         </xsl:if>
631         <xsl:value-of select="local-name($node)"/>
632     </xsl:template>
633
634     <xsl:template match="*" mode="xml-highlight">
635         <span dactyl:highlight="HelpXMLTagStart">
636             <xsl:text>&lt;</xsl:text>
637             <xsl:call-template name="xml-namespace"/>
638             <xsl:apply-templates select="@*" mode="xml-highlight"/>
639             <xsl:text>/></xsl:text>
640         </span>
641     </xsl:template>
642
643     <xsl:template match="*[node()]" mode="xml-highlight">
644         <span dactyl:highlight="HelpXMLTagStart">
645             <xsl:text>&lt;</xsl:text>
646             <xsl:call-template name="xml-namespace"/>
647             <xsl:apply-templates select="@*" mode="xml-highlight"/>
648             <xsl:text>></xsl:text>
649         </span>
650         <xsl:apply-templates select="node()" mode="xml-highlight"/>
651         <span dactyl:highlight="HelpXMLTagEnd">
652             <xsl:text>&lt;/</xsl:text>
653             <xsl:call-template name="xml-namespace"/>
654             <xsl:text>></xsl:text>
655         </span>
656     </xsl:template>
657
658     <xsl:template match="dactyl:escape | dactyl:escape[node()]" mode="xml-highlight">
659         <span dactyl:highlight="HelpXMLText">
660             <xsl:apply-templates mode="help-1"/>
661         </span>
662     </xsl:template>
663
664     <xsl:template match="@*" mode="xml-highlight">
665         <xsl:text> </xsl:text>
666         <span dactyl:highlight="HelpXMLAttribute">
667             <xsl:call-template name="xml-namespace"/>
668         </span>
669         <span dactyl:highlight="HelpXMLString">
670             <xsl:value-of select="regexp:replace(., '&quot;', 'g', '&amp;quot;')"/>
671         </span>
672     </xsl:template>
673
674     <xsl:template match="comment()" mode="xml-highlight">
675         <span dactyl:highlight="HelpXMLComment">
676             <xsl:value-of select="."/>
677         </span>
678     </xsl:template>
679
680     <xsl:template match="processing-instruction()" mode="xml-highlight">
681         <span dactyl:highlight="HelpXMLProcessing">
682             <xsl:value-of select="."/>
683         </span>
684     </xsl:template>
685
686     <xsl:template match="text()" mode="xml-highlight">
687         <span dactyl:highlight="HelpXMLText">
688             <xsl:value-of select="regexp:replace(., '&lt;', 'g', '&amp;lt;')"/>
689         </span>
690     </xsl:template>
691 </xsl:stylesheet>
692
693 <!-- vim:se ft=xslt sts=4 sw=4 et fdm=marker: -->