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