Debian Codegraph @

xslt/mallard/html/mal2html-block.xsl

raw
1 <?xml version='1.0' encoding='UTF-8'?><!-- -*- indent-tabs-mode: nil -*- -->
2 <!--
3 This program is free software; you can redistribute it and/or modify it under
4 the terms of the GNU Lesser General Public License as published by the Free
5 Software Foundation; either version 2 of the License, or (at your option) any
6 later version.
7
8 This program is distributed in the hope that it will be useful, but WITHOUT
9 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
10 FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
11 details.
12
13 You should have received a copy of the GNU Lesser General Public License
14 along with this program; see the file COPYING.LGPL. If not, see <http://www.gnu.org/licenses/>.
15 -->
16
17 <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
18 xmlns:mal="http://projectmallard.org/1.0/"
19 xmlns:if="http://projectmallard.org/if/1.0/"
20 xmlns:ui="http://projectmallard.org/ui/1.0/"
21 xmlns:uix="http://projectmallard.org/experimental/ui/"
22 xmlns:msg="http://projects.gnome.org/yelp/gettext/"
23 xmlns="http://www.w3.org/1999/xhtml"
24 exclude-result-prefixes="mal if ui uix msg"
25 version="1.0">
26
27 <!--!!==========================================================================
28 Mallard to HTML - Blocks
29 Handle simple Mallard block elements.
30 @revision[version=1.0 date=2010-06-03 status=final]
31
32 This stylesheet contains templates for handling most Mallard block elements,
33 except the list and table elements.
34 -->
35
36
37 <!--**==========================================================================
38 mal2html.pre
39 Output an HTML `pre` element.
40 @revision[version=3.12 date=2013-11-02 status=final]
41 $node: The source element to output a `pre` for.
42
43 This template outputs an HTML `pre` element along with a wrapper `div` element
44 for CSS styling. It should be called for verbatim block elements. It will
45 automatically strip leading and trailing newlines using {utils.strip_newlines}.
46
47 If {html.syntax.highlight} is `true`, this template automatically outputs
48 syntax highlighting support based on the `mime` attribute of $node, using
49 {html.syntax.class} to determine the correct highlighter.
50 -->
51 <xsl:template name="mal2html.pre">
52 <xsl:param name="node" select="."/>
53 <xsl:param name="numbered" select="contains(concat(' ', @style, ' '), ' numbered ')"/>
54 <xsl:variable name="if">
55 <xsl:call-template name="mal.if.test">
56 <xsl:with-param name="node" select="$node"/>
57 </xsl:call-template>
58 </xsl:variable>
59 <xsl:if test="$if != ''">
60 <xsl:variable name="first" select="$node/node()[1]/self::text()"/>
61 <xsl:variable name="last" select="$node/node()[last()]/self::text()"/>
62 <div>
63 <xsl:call-template name="html.lang.attrs">
64 <xsl:with-param name="node" select="$node"/>
65 </xsl:call-template>
66 <xsl:call-template name="html.class.attr">
67 <xsl:with-param name="node" select="$node"/>
68 <xsl:with-param name="class">
69 <xsl:value-of select="local-name($node)"/>
70 <xsl:if test="$if != 'true'">
71 <xsl:text> if-if </xsl:text>
72 <xsl:value-of select="$if"/>
73 </xsl:if>
74 </xsl:with-param>
75 </xsl:call-template>
76 <xsl:if test="$numbered">
77 <pre class="numbered"><xsl:call-template name="utils.linenumbering">
78 <xsl:with-param name="node" select="$node"/>
79 </xsl:call-template></pre>
80 </xsl:if>
81 <pre class="contents"><code>
82 <xsl:if test="$html.syntax.highlight and ($node/@mime or $node/@type)">
83 <xsl:attribute name="class">
84 <xsl:call-template name="html.syntax.class">
85 <xsl:with-param name="node" select="$node"/>
86 </xsl:call-template>
87 </xsl:attribute>
88 </xsl:if>
89 <xsl:if test="$first">
90 <xsl:call-template name="utils.strip_newlines">
91 <xsl:with-param name="string" select="$first"/>
92 <xsl:with-param name="leading" select="true()"/>
93 <xsl:with-param name="trailing" select="count(node()) = 1"/>
94 </xsl:call-template>
95 </xsl:if>
96 <xsl:apply-templates mode="mal2html.inline.mode"
97 select="node()[not(self::text() and (position() = 1 or position() = last()))]"/>
98 <xsl:if test="$last and (count(node()) != 1)">
99 <xsl:call-template name="utils.strip_newlines">
100 <xsl:with-param name="string" select="$last"/>
101 <xsl:with-param name="leading" select="false()"/>
102 <xsl:with-param name="trailing" select="true()"/>
103 </xsl:call-template>
104 </xsl:if>
105 </code></pre>
106 </div>
107 </xsl:if>
108 </xsl:template>
109
110
111 <!--%%==========================================================================
112 mal2html.block.mode
113 Process Mallard elements in block mode.
114 @revision[version=1.0 date=2010-06-03 status=final]
115 $restricted: Whether this is restricted block mode.
116
117 This mode is applied to elements in block context. It should be called by
118 templates for pages, sections, and block container elements. Certain elements
119 may appear in both block an inline mode, and the processing expectations for
120 those elements is different depending on context.
121
122 Implementations of this mode should generally output a wrapper div and process
123 the child elements, either in {mal2html.block.mode} or {mal2html.inline.mode},
124 or using special processing for particular content models.
125
126 When this mode encounters unknown content, templates in the same mode are
127 applied to the children, but the $restricted parameter is set to `true`.
128 When $restricted is `true`, unknown block elements are ignored. This is
129 in accordance with the Mallard specification on fallback block content.
130 -->
131 <xsl:template mode="mal2html.block.mode" match="*">
132 <xsl:param name="restricted" select="false()"/>
133 <xsl:if test="not($restricted)">
134 <xsl:message>
135 <xsl:text>Unmatched block element: </xsl:text>
136 <xsl:value-of select="local-name(.)"/>
137 </xsl:message>
138 <xsl:variable name="if"><xsl:call-template name="mal.if.test"/></xsl:variable>
139 <xsl:if test="$if != ''">
140 <div>
141 <xsl:call-template name="html.lang.attrs"/>
142 <xsl:call-template name="html.class.attr">
143 <xsl:with-param name="class">
144 <xsl:text>unknown </xsl:text>
145 <xsl:call-template name="mal2html.ui.expander.class"/>
146 <xsl:if test="$if != 'true'">
147 <xsl:text> if-if </xsl:text>
148 <xsl:value-of select="$if"/>
149 </xsl:if>
150 </xsl:with-param>
151 </xsl:call-template>
152 <xsl:call-template name="mal2html.ui.expander.data"/>
153 <div class="inner">
154 <xsl:apply-templates mode="mal2html.block.mode" select="mal:title[1]"/>
155 <div class="region">
156 <xsl:apply-templates mode="mal2html.block.mode" select="mal:desc[1]"/>
157 <div class="contents">
158 <xsl:for-each select="*[not(self::mal:title or self::mal:desc)]">
159 <xsl:apply-templates mode="mal2html.block.mode" select=".">
160 <xsl:with-param name="restricted" select="true()"/>
161 </xsl:apply-templates>
162 </xsl:for-each>
163 </div>
164 </div>
165 </div>
166 </div>
167 </xsl:if>
168 </xsl:if>
169 </xsl:template>
170
171 <xsl:template mode="mal2html.block.mode" match="text()"/>
172
173
174 <!-- = desc = -->
175 <xsl:template mode="mal2html.block.mode" match="mal:desc">
176 <div>
177 <xsl:call-template name="html.class.attr">
178 <xsl:with-param name="class">
179 <xsl:text>desc</xsl:text>
180 <xsl:if test="contains(concat(' ', @style, ' '), ' center ')">
181 <xsl:text> center</xsl:text>
182 </xsl:if>
183 </xsl:with-param>
184 </xsl:call-template>
185 <xsl:call-template name="html.lang.attrs"/>
186 <xsl:apply-templates mode="mal2html.inline.mode"/>
187 </div>
188 </xsl:template>
189
190 <!-- = code = -->
191 <xsl:template mode="mal2html.block.mode" match="mal:code">
192 <xsl:call-template name="mal2html.pre"/>
193 </xsl:template>
194
195 <xsl:template mode="html.syntax.class.mode" match="mal:code | mal:screen">
196 <xsl:variable name="type" select="concat(' ', translate(@type,
197 'ABCDEFGHIJKLMNOPQRSTUVWXYX',
198 'abcdefghijklmnopqrstuvwxyz'),
199 ' ')"/>
200 <xsl:choose>
201 <!-- First do checks for embedded and derivative things, where people
202 might reasonably put other matched values in the type attribute. -->
203 <!-- Clojure -->
204 <xsl:when test="@mime = 'application/x-clojure' or
205 contains($type, ' clojure ') or contains($type, ' clj ')">
206 <xsl:text>clojure</xsl:text>
207 </xsl:when>
208 <!-- Django -->
209 <xsl:when test="@mime = 'application/x-django-templating' or contains($type, ' django ')">
210 <xsl:text>django</xsl:text>
211 </xsl:when>
212 <!-- Embedded Ruby -->
213 <xsl:when test="@mime = 'application/x-ruby-templating' or contains($type, ' erb ')">
214 <xsl:text>erb</xsl:text>
215 </xsl:when>
216 <!-- JSON -->
217 <xsl:when test="@mime = 'application/json' or contains($type, ' json ')">
218 <xsl:text>json</xsl:text>
219 </xsl:when>
220 <!-- PHP -->
221 <xsl:when test="@mime = 'application/x-php' or contains($type, ' php ')">
222 <xsl:text>php</xsl:text>
223 </xsl:when>
224 <!-- Scheme -->
225 <xsl:when test="@mime = 'text/x-scheme' or
226 contains($type, ' scheme ') or contains($type, ' scm ')">
227 <xsl:text>scheme</xsl:text>
228 </xsl:when>
229
230 <!-- Then do the rest of the checks. -->
231 <!-- ActionScript -->
232 <xsl:when test="@mime = 'application/x-actionscript' or contains($type, ' actionscript ')">
233 <xsl:text>actionscript</xsl:text>
234 </xsl:when>
235 <!-- Apache -->
236 <xsl:when test="@mime = 'text/x-apacheconf' or contains($type, ' apache ')">
237 <xsl:text>apache</xsl:text>
238 </xsl:when>
239 <!-- AsciiDoc -->
240 <xsl:when test="@mime = 'text/x-asciidoc' or
241 contains($type, ' asciidoc ') or contains($type, ' adoc ')">
242 <xsl:text>asciidoc</xsl:text>
243 </xsl:when>
244 <!-- Awk -->
245 <xsl:when test="contains($type, ' awk ')">
246 <xsl:text>awk</xsl:text>
247 </xsl:when>
248 <!-- Bash -->
249 <xsl:when test="@mime = 'application/x-shellscript' or
250 contains($type, ' sh ') or contains($type, ' bash ') or
251 contains($type, ' csh ')">
252 <xsl:text>bash</xsl:text>
253 </xsl:when>
254 <!-- C -->
255 <xsl:when test="@mime = 'text/x-csrc' or @mime = 'text/x-chdr' or
256 contains($type, ' c ')">
257 <xsl:text>c</xsl:text>
258 </xsl:when>
259 <!-- C# -->
260 <xsl:when test="@mime = 'text/x-csharp' or
261 contains($type, ' cs ') or contains($type, ' csharp ')">
262 <xsl:text>csharp</xsl:text>
263 </xsl:when>
264 <!-- C++ -->
265 <xsl:when test="@mime = 'text/x-c++hdr' or @mime = 'text/x-c++src' or
266 contains($type, ' cpp ') or contains($type, ' c++ ')">
267 <xsl:text>cpp</xsl:text>
268 </xsl:when>
269 <!-- CMake -->
270 <xsl:when test="@mime = 'text/x-cmake' or contains($type, ' cmake ')">
271 <xsl:text>cmake</xsl:text>
272 </xsl:when>
273 <!-- CSS -->
274 <xsl:when test="@mime = 'text/css' or contains($type, ' css ')">
275 <xsl:text>css</xsl:text>
276 </xsl:when>
277 <!-- D -->
278 <xsl:when test="@mime = 'text/x-d' or contains($type, ' d ')">
279 <xsl:text>d</xsl:text>
280 </xsl:when>
281 <!-- Diff -->
282 <xsl:when test="@mime = 'text/x-diff' or @mime = 'text/x-patch' or
283 contains($type, ' diff ') or contains($type, ' patch ')">
284 <xsl:text>diff</xsl:text>
285 </xsl:when>
286 <!-- Dockerfile -->
287 <xsl:when test="contains($type, ' dockerfile ')">
288 <xsl:text>dockerfile</xsl:text>
289 </xsl:when>
290 <!-- DOS -->
291 <xsl:when test="@mime = 'application/x-dos-batch' or contains($type, ' dos ')">
292 <xsl:text>dos</xsl:text>
293 </xsl:when>
294 <!-- Ducktype -->
295 <xsl:when test="contains($type, ' ducktype ')">
296 <xsl:text>ducktype</xsl:text>
297 </xsl:when>
298 <!-- F# -->
299 <xsl:when test="@mime = 'text/x-fsharp' or contains($type, ' fsharp ')">
300 <xsl:text>fsharp</xsl:text>
301 </xsl:when>
302 <!-- Go -->
303 <xsl:when test="@mime = 'text/x-go' or contains($type, ' go ')">
304 <xsl:text>go</xsl:text>
305 </xsl:when>
306 <!-- Haml -->
307 <xsl:when test="@mime = 'text/x-haml' or contains($type, ' haml ')">
308 <xsl:text>haml</xsl:text>
309 </xsl:when>
310 <!-- Haskell -->
311 <xsl:when test="@mime = 'text/x-haskell' or
312 contains($type, ' haskell ') or contains($type, ' hs ')">
313 <xsl:text>hs</xsl:text>
314 </xsl:when>
315 <!-- HTML -->
316 <xsl:when test="@mime = 'text/html' or
317 contains($type, ' html ') or contains($type, ' xhtml ')">
318 <xsl:text>html</xsl:text>
319 </xsl:when>
320 <!-- HTTP -->
321 <xsl:when test="contains($type, ' http ')">
322 <xsl:text>http</xsl:text>
323 </xsl:when>
324 <!-- INI -->
325 <xsl:when test="contains($type, ' ini ')">
326 <xsl:text>ini</xsl:text>
327 </xsl:when>
328 <!-- Java -->
329 <xsl:when test="@mime = 'text/x-java' or contains($type, ' java ')">
330 <xsl:text>java</xsl:text>
331 </xsl:when>
332 <!-- Javascript -->
333 <xsl:when test="@mime = 'application/javascript' or
334 contains($type, ' js ') or contains($type, ' javascript ')">
335 <xsl:text>javascript</xsl:text>
336 </xsl:when>
337 <!-- LISP -->
338 <xsl:when test="@mime = 'application/x-lisp' or @mime = 'text/x-emacs-lisp' or
339 contains($type, ' lisp ') or contains($type, ' el ') or
340 contains($type, ' cl ') or contains($type, ' lsp ')">
341 <xsl:text>lisp</xsl:text>
342 </xsl:when>
343 <!-- Lua -->
344 <xsl:when test="@mime = 'text/x-lua' or contains($type, ' lua ')">
345 <xsl:text>lua</xsl:text>
346 </xsl:when>
347 <!-- Makefile -->
348 <xsl:when test="@mime = 'text/x-makefile' or
349 contains($type, ' makefile ') or contains($type, ' make ')">
350 <xsl:text>makefile</xsl:text>
351 </xsl:when>
352 <!-- Markdown -->
353 <xsl:when test="@mime = 'text/x-markdown' or
354 contains($type, ' markdown ') or contains($type, ' md ')">
355 <xsl:text>markdown</xsl:text>
356 </xsl:when>
357 <!-- MATLAB/Octave -->
358 <xsl:when test="@mime = 'text/x-matlab' or @mime = 'text/x-octave' or
359 contains($type, ' matlab ') or contains($type, ' octave ')">
360 <xsl:text>matlab</xsl:text>
361 </xsl:when>
362 <!-- Nginx -->
363 <xsl:when test="@mime = 'text/x-nginx-conf' or contains($type, ' nginx ')">
364 <xsl:text>nginx</xsl:text>
365 </xsl:when>
366 <!-- Objective C -->
367 <xsl:when test="@mime = 'text/x-objcsrc' or
368 contains($type, ' objc ') or contains($type, ' m ')">
369 <xsl:text>objectivec</xsl:text>
370 </xsl:when>
371 <!-- Perl -->
372 <xsl:when test="@mime = 'application/x-perl' or contains($type, ' perl ') or
373 contains($type, ' pl ') or contains($type, ' pm ')">
374 <xsl:text>perl</xsl:text>
375 </xsl:when>
376 <!-- Python -->
377 <xsl:when test="@mime = 'text/x-python' or
378 contains($type, ' py ') or contains($type, ' python ')">
379 <xsl:text>python</xsl:text>
380 </xsl:when>
381 <!-- R/S -->
382 <xsl:when test="@mime = 'text/x-r' or @mime = 'text/x-s' or
383 contains($type, ' r ') or contains($type, ' s ')">
384 <xsl:text>r</xsl:text>
385 </xsl:when>
386 <!-- Ruby -->
387 <xsl:when test="@mime = 'application/x-ruby' or
388 contains($type, ' ruby ') or contains($type, ' rb ')">
389 <xsl:text>ruby</xsl:text>
390 </xsl:when>
391 <!-- Rust -->
392 <xsl:when test="@mime = 'text/x-rust' or contains($type, ' rust ')">
393 <xsl:text>rust</xsl:text>
394 </xsl:when>
395 <!-- Scala -->
396 <xsl:when test="@mime = 'text/x-scala' or contains($type, ' scala ')">
397 <xsl:text>scala</xsl:text>
398 </xsl:when>
399 <!-- Shell -->
400 <xsl:when test="contains($type, ' shell ')">
401 <xsl:text>shell</xsl:text>
402 </xsl:when>
403 <!-- Smalltalk -->
404 <xsl:when test="@mime = 'text/x-smalltalk' or contains($type, ' smalltalk ')">
405 <xsl:text>smalltalk</xsl:text>
406 </xsl:when>
407 <!-- SML -->
408 <xsl:when test="contains($type, ' sml ')">
409 <xsl:text>sml</xsl:text>
410 </xsl:when>
411 <!-- SQL -->
412 <xsl:when test="@mime = 'application/sql' or contains($type, ' sql ')">
413 <xsl:text>sql</xsl:text>
414 </xsl:when>
415 <!-- TCL -->
416 <xsl:when test="@mime = 'application/x-tcl' or @mime = 'text/x-tcl' or
417 contains($type, ' tcl ')">
418 <xsl:text>tcl</xsl:text>
419 </xsl:when>
420 <!-- TeX -->
421 <xsl:when test="@mime = 'text/x-tex' or
422 contains($type, ' tex ') or contains($type, ' latex ')">
423 <xsl:text>latex</xsl:text>
424 </xsl:when>
425 <!-- Vala -->
426 <xsl:when test="@mime = 'text/x-vala' or contains($type, ' vala ')">
427 <xsl:text>vala</xsl:text>
428 </xsl:when>
429 <!-- XML -->
430 <xsl:when test="@mime = 'application/xml' or
431 substring(@mime, string-length(@mime) - 3) = '+xml'
432 or contains($type, ' xml ')">
433 <xsl:text>xml</xsl:text>
434 </xsl:when>
435 <!-- XQuery -->
436 <xsl:when test="@mime = 'application/xquery' or
437 contains($type, ' xq ') or contains($type, ' xquery ')">
438 <xsl:text>xquery</xsl:text>
439 </xsl:when>
440 <!-- YAML -->
441 <xsl:when test="@mime = 'application/x-yaml' or contains($type, ' yaml ')">
442 <xsl:text>yaml</xsl:text>
443 </xsl:when>
444 </xsl:choose>
445 </xsl:template>
446
447 <!-- = comment = -->
448 <xsl:template mode="mal2html.block.mode" match="mal:comment">
449 <xsl:variable name="if"><xsl:call-template name="mal.if.test"/></xsl:variable><xsl:if test="$if != ''">
450 <xsl:if test="$mal2html.editor_mode
451 or processing-instruction('mal2html.show_comment')">
452 <div>
453 <xsl:call-template name="html.lang.attrs"/>
454 <xsl:call-template name="html.class.attr">
455 <xsl:with-param name="class">
456 <xsl:text>comment </xsl:text>
457 <xsl:call-template name="mal2html.ui.expander.class"/>
458 <xsl:if test="$if != 'true'">
459 <xsl:text> if-if </xsl:text>
460 <xsl:value-of select="$if"/>
461 </xsl:if>
462 </xsl:with-param>
463 </xsl:call-template>
464 <xsl:call-template name="mal2html.ui.expander.data"/>
465 <div class="inner">
466 <xsl:apply-templates mode="mal2html.block.mode" select="mal:title"/>
467 <div class="region">
468 <xsl:apply-templates mode="mal2html.block.mode" select="mal:cite"/>
469 <div class="contents">
470 <xsl:for-each select="*[not(self::mal:title or self::mal:cite)]">
471 <xsl:apply-templates mode="mal2html.block.mode" select="."/>
472 </xsl:for-each>
473 </div>
474 </div>
475 </div>
476 </div>
477 </xsl:if>
478 </xsl:if>
479 </xsl:template>
480
481 <!-- = comment/cite = -->
482 <xsl:template mode="mal2html.block.mode" match="mal:comment/mal:cite">
483 <div>
484 <xsl:call-template name="html.class.attr">
485 <xsl:with-param name="class" select="'cite cite-comment'"/>
486 </xsl:call-template>
487 <xsl:call-template name="html.lang.attrs"/>
488 <xsl:choose>
489 <xsl:when test="@date">
490 <xsl:call-template name="l10n.gettext">
491 <xsl:with-param name="msgid" select="'comment.name-date'"/>
492 <xsl:with-param name="node" select="."/>
493 <xsl:with-param name="format" select="true()"/>
494 </xsl:call-template>
495 </xsl:when>
496 <xsl:otherwise>
497 <xsl:call-template name="l10n.gettext">
498 <xsl:with-param name="msgid" select="'comment.name'"/>
499 <xsl:with-param name="node" select="."/>
500 <xsl:with-param name="format" select="true()"/>
501 </xsl:call-template>
502 </xsl:otherwise>
503 </xsl:choose>
504 </div>
505 </xsl:template>
506
507 <xsl:template mode="l10n.format.mode" match="msg:comment.name">
508 <xsl:param name="node"/>
509 <xsl:choose>
510 <xsl:when test="$node/@href">
511 <a href="{$node/@href}">
512 <xsl:apply-templates mode="mal2html.inline.mode" select="$node/node()"/>
513 </a>
514 </xsl:when>
515 <xsl:otherwise>
516 <xsl:apply-templates mode="mal2html.inline.mode" select="$node/node()"/>
517 </xsl:otherwise>
518 </xsl:choose>
519 </xsl:template>
520
521 <xsl:template mode="l10n.format.mode" match="msg:comment.date">
522 <xsl:param name="node"/>
523 <xsl:value-of select="$node/@date"/>
524 </xsl:template>
525
526 <!-- = div = -->
527 <xsl:template mode="mal2html.block.mode" match="mal:div">
528 <xsl:variable name="if"><xsl:call-template name="mal.if.test"/></xsl:variable><xsl:if test="$if != ''">
529 <div>
530 <xsl:call-template name="html.lang.attrs"/>
531 <xsl:call-template name="html.class.attr">
532 <xsl:with-param name="class">
533 <xsl:text>div </xsl:text>
534 <xsl:call-template name="mal2html.ui.expander.class"/>
535 <xsl:if test="$if != 'true'">
536 <xsl:text> if-if </xsl:text>
537 <xsl:value-of select="$if"/>
538 </xsl:if>
539 </xsl:with-param>
540 </xsl:call-template>
541 <xsl:call-template name="mal2html.ui.expander.data"/>
542 <div class="inner">
543 <xsl:apply-templates mode="mal2html.block.mode" select="mal:title[1]"/>
544 <div class="region">
545 <xsl:apply-templates mode="mal2html.block.mode" select="mal:desc[1]"/>
546 <div class="contents">
547 <xsl:for-each select="*[not(self::mal:title or self::mal:desc)]">
548 <xsl:apply-templates mode="mal2html.block.mode" select="."/>
549 </xsl:for-each>
550 </div>
551 </div>
552 </div>
553 </div>
554 </xsl:if>
555 </xsl:template>
556
557 <!-- = example = -->
558 <xsl:template mode="mal2html.block.mode" match="mal:example">
559 <xsl:variable name="if"><xsl:call-template name="mal.if.test"/></xsl:variable><xsl:if test="$if != ''">
560 <div>
561 <xsl:call-template name="html.lang.attrs"/>
562 <xsl:call-template name="html.class.attr">
563 <xsl:with-param name="class">
564 <xsl:text>example </xsl:text>
565 <xsl:call-template name="mal2html.ui.expander.class"/>
566 <xsl:if test="$if != 'true'">
567 <xsl:text> if-if </xsl:text>
568 <xsl:value-of select="$if"/>
569 </xsl:if>
570 </xsl:with-param>
571 </xsl:call-template>
572 <xsl:call-template name="mal2html.ui.expander.data"/>
573 <div class="inner">
574 <xsl:apply-templates mode="mal2html.block.mode" select="mal:title[1]"/>
575 <div class="region">
576 <xsl:apply-templates mode="mal2html.block.mode" select="mal:desc[1]"/>
577 <div class="contents">
578 <xsl:for-each select="*[not(self::mal:title or self::mal:desc)]">
579 <xsl:apply-templates mode="mal2html.block.mode" select="."/>
580 </xsl:for-each>
581 </div>
582 </div>
583 </div>
584 </div>
585 </xsl:if>
586 </xsl:template>
587
588 <!-- = figure = -->
589 <xsl:template mode="mal2html.block.mode" match="mal:figure">
590 <xsl:variable name="if"><xsl:call-template name="mal.if.test"/></xsl:variable><xsl:if test="$if != ''">
591 <div>
592 <xsl:call-template name="html.lang.attrs"/>
593 <xsl:call-template name="html.class.attr">
594 <xsl:with-param name="class">
595 <xsl:text>figure </xsl:text>
596 <xsl:call-template name="mal2html.ui.expander.class"/>
597 <xsl:if test="$if != 'true'">
598 <xsl:text> if-if </xsl:text>
599 <xsl:value-of select="$if"/>
600 </xsl:if>
601 </xsl:with-param>
602 </xsl:call-template>
603 <xsl:call-template name="mal2html.ui.expander.data"/>
604 <div class="inner">
605 <a href="#" class="figure-zoom">
606 <xsl:attribute name="data-zoom-in-title">
607 <xsl:call-template name="l10n.gettext">
608 <xsl:with-param name="msgid" select="'View images at normal size'"/>
609 </xsl:call-template>
610 </xsl:attribute>
611 <xsl:attribute name="data-zoom-out-title">
612 <xsl:call-template name="l10n.gettext">
613 <xsl:with-param name="msgid" select="'Scale images down'"/>
614 </xsl:call-template>
615 </xsl:attribute>
616 <xsl:call-template name="icons.svg.figure.zoom.in"/>
617 <xsl:call-template name="icons.svg.figure.zoom.out"/>
618 </a>
619 <xsl:apply-templates mode="mal2html.block.mode" select="mal:title[1]"/>
620 <div class="region">
621 <div class="contents">
622 <xsl:for-each select="*[not(self::mal:title or self::mal:desc)]">
623 <xsl:apply-templates mode="mal2html.block.mode" select="."/>
624 </xsl:for-each>
625 </div>
626 <xsl:apply-templates mode="mal2html.block.mode" select="mal:desc[1]"/>
627 </div>
628 </div>
629 </div>
630 </xsl:if>
631 </xsl:template>
632
633 <!-- = listing = -->
634 <xsl:template mode="mal2html.block.mode" match="mal:listing">
635 <xsl:variable name="if"><xsl:call-template name="mal.if.test"/></xsl:variable><xsl:if test="$if != ''">
636 <div>
637 <xsl:call-template name="html.lang.attrs"/>
638 <xsl:call-template name="html.class.attr">
639 <xsl:with-param name="class">
640 <xsl:text>listing </xsl:text>
641 <xsl:call-template name="mal2html.ui.expander.class"/>
642 <xsl:if test="$if != 'true'">
643 <xsl:text> if-if </xsl:text>
644 <xsl:value-of select="$if"/>
645 </xsl:if>
646 </xsl:with-param>
647 </xsl:call-template>
648 <xsl:call-template name="mal2html.ui.expander.data"/>
649 <div class="inner">
650 <xsl:apply-templates mode="mal2html.block.mode" select="mal:title[1]"/>
651 <div class="region">
652 <xsl:apply-templates mode="mal2html.block.mode" select="mal:desc[1]"/>
653 <div class="contents">
654 <xsl:for-each select="*[not(self::mal:title or self::mal:desc)]">
655 <xsl:apply-templates mode="mal2html.block.mode" select="."/>
656 </xsl:for-each>
657 </div>
658 </div>
659 </div>
660 </div>
661 </xsl:if>
662 </xsl:template>
663
664 <!-- = note = -->
665 <xsl:template mode="mal2html.block.mode" match="mal:note">
666 <xsl:variable name="if"><xsl:call-template name="mal.if.test"/></xsl:variable><xsl:if test="$if != ''">
667 <xsl:variable name="style" select="concat(' ', @style, ' ')"/>
668 <xsl:variable name="notetitle">
669 <xsl:choose>
670 <xsl:when test="contains($style, ' advanced ')">
671 <xsl:text>Advanced</xsl:text>
672 </xsl:when>
673 <xsl:when test="contains($style, ' bug ')">
674 <xsl:text>Bug</xsl:text>
675 </xsl:when>
676 <xsl:when test="contains($style, ' caution ')">
677 <xsl:text>Caution</xsl:text>
678 </xsl:when>
679 <xsl:when test="contains($style, ' danger ')">
680 <xsl:text>Danger</xsl:text>
681 </xsl:when>
682 <xsl:when test="contains($style, ' important ')">
683 <xsl:text>Important</xsl:text>
684 </xsl:when>
685 <xsl:when test="contains($style, ' package ')">
686 <xsl:text>Package</xsl:text>
687 </xsl:when>
688 <xsl:when test="contains($style, ' plain ')">
689 <xsl:text>plain</xsl:text>
690 </xsl:when>
691 <xsl:when test="contains($style, ' sidebar ')">
692 <xsl:text>Sidebar</xsl:text>
693 </xsl:when>
694 <xsl:when test="contains($style, ' tip ')">
695 <xsl:text>Tip</xsl:text>
696 </xsl:when>
697 <xsl:when test="contains($style, ' warning ')">
698 <xsl:text>Warning</xsl:text>
699 </xsl:when>
700 <xsl:otherwise>
701 <xsl:text>Note</xsl:text>
702 </xsl:otherwise>
703 </xsl:choose>
704 </xsl:variable>
705 <xsl:variable name="notestyle">
706 <xsl:value-of select="translate($notetitle,
707 'ABCDEFGHIJKLMNOPQRSTUVWXYZ',
708 'abcdefghijklmnopqrstuvwxyz')"/>
709 </xsl:variable>
710 <div>
711 <xsl:call-template name="html.lang.attrs"/>
712 <xsl:call-template name="html.class.attr">
713 <xsl:with-param name="class">
714 <xsl:text>note</xsl:text>
715 <xsl:if test="$notestyle != 'note'">
716 <xsl:value-of select="concat(' note-', $notestyle)"/>
717 </xsl:if>
718 <xsl:text> </xsl:text>
719 <xsl:call-template name="mal2html.ui.expander.class"/>
720 <xsl:if test="$if != 'true'">
721 <xsl:text> if-if </xsl:text>
722 <xsl:value-of select="$if"/>
723 </xsl:if>
724 </xsl:with-param>
725 </xsl:call-template>
726 <xsl:if test="$notestyle != 'plain'">
727 <xsl:attribute name="title">
728 <xsl:call-template name="l10n.gettext">
729 <xsl:with-param name="msgid" select="$notetitle"/>
730 </xsl:call-template>
731 </xsl:attribute>
732 </xsl:if>
733 <xsl:call-template name="mal2html.ui.expander.data"/>
734 <xsl:if test="$notestyle != 'plain' and $notestyle != 'sidebar'">
735 <xsl:call-template name="icons.svg.note">
736 <xsl:with-param name="style" select="$notestyle"/>
737 </xsl:call-template>
738 </xsl:if>
739 <div class="inner">
740 <xsl:apply-templates mode="mal2html.block.mode" select="mal:title"/>
741 <div class="region">
742 <div class="contents">
743 <xsl:apply-templates mode="mal2html.block.mode" select="*[not(self::mal:title)]"/>
744 </div>
745 </div>
746 </div>
747 </div>
748 </xsl:if>
749 </xsl:template>
750
751 <!-- = info = -->
752 <xsl:template mode="mal2html.block.mode" match="mal:info"/>
753
754 <!-- = p = -->
755 <xsl:template mode="mal2html.block.mode" match="mal:p">
756 <xsl:variable name="if"><xsl:call-template name="mal.if.test"/></xsl:variable><xsl:if test="$if != ''">
757 <p>
758 <xsl:call-template name="html.class.attr">
759 <xsl:with-param name="class">
760 <xsl:text>p</xsl:text>
761 <xsl:if test="contains(concat(' ', @style, ' '), ' lead ')">
762 <xsl:text> lead</xsl:text>
763 </xsl:if>
764 <xsl:if test="$if != 'true'">
765 <xsl:text> if-if </xsl:text>
766 <xsl:value-of select="$if"/>
767 </xsl:if>
768 </xsl:with-param>
769 </xsl:call-template>
770 <xsl:call-template name="html.lang.attrs"/>
771 <xsl:apply-templates mode="mal2html.inline.mode"/>
772 </p>
773 </xsl:if>
774 </xsl:template>
775
776 <!-- = quote = -->
777 <xsl:template mode="mal2html.block.mode" match="mal:quote">
778 <xsl:variable name="if"><xsl:call-template name="mal.if.test"/></xsl:variable><xsl:if test="$if != ''">
779 <div>
780 <xsl:call-template name="html.lang.attrs"/>
781 <xsl:call-template name="html.class.attr">
782 <xsl:with-param name="class">
783 <xsl:text>quote </xsl:text>
784 <xsl:call-template name="mal2html.ui.expander.class"/>
785 <xsl:if test="$if != 'true'">
786 <xsl:text> if-if </xsl:text>
787 <xsl:value-of select="$if"/>
788 </xsl:if>
789 </xsl:with-param>
790 </xsl:call-template>
791 <xsl:call-template name="mal2html.ui.expander.data"/>
792 <div class="inner">
793 <xsl:apply-templates mode="mal2html.block.mode" select="mal:title"/>
794 <div class="region">
795 <blockquote class="contents">
796 <xsl:for-each select="*[not(self::mal:title or self::mal:cite)]">
797 <xsl:apply-templates mode="mal2html.block.mode" select="."/>
798 </xsl:for-each>
799 </blockquote>
800 <xsl:apply-templates mode="mal2html.block.mode" select="mal:cite"/>
801 </div>
802 </div>
803 </div>
804 </xsl:if>
805 </xsl:template>
806
807 <!-- = quote/cite = -->
808 <xsl:template mode="mal2html.block.mode" match="mal:quote/mal:cite">
809 <div>
810 <xsl:call-template name="html.class.attr">
811 <xsl:with-param name="class" select="'cite cite-quote'"/>
812 </xsl:call-template>
813 <xsl:call-template name="html.lang.attrs"/>
814 <xsl:choose>
815 <xsl:when test="@href">
816 <a href="{@href}">
817 <xsl:apply-templates mode="mal2html.inline.mode"/>
818 </a>
819 </xsl:when>
820 <xsl:otherwise>
821 <xsl:apply-templates mode="mal2html.inline.mode"/>
822 </xsl:otherwise>
823 </xsl:choose>
824 <!-- FIXME: i18n -->
825 <xsl:if test="@date">
826 <xsl:text> (</xsl:text>
827 <xsl:value-of select="@date"/>
828 <xsl:text>)</xsl:text>
829 </xsl:if>
830 </div>
831 </xsl:template>
832
833 <!-- = screen = -->
834 <xsl:template mode="mal2html.block.mode" match="mal:screen">
835 <xsl:call-template name="mal2html.pre"/>
836 </xsl:template>
837
838 <!-- = synopsis = -->
839 <xsl:template mode="mal2html.block.mode" match="mal:synopsis">
840 <xsl:variable name="if"><xsl:call-template name="mal.if.test"/></xsl:variable><xsl:if test="$if != ''">
841 <div>
842 <xsl:call-template name="html.lang.attrs"/>
843 <xsl:call-template name="html.class.attr">
844 <xsl:with-param name="class">
845 <xsl:text>synopsis </xsl:text>
846 <xsl:call-template name="mal2html.ui.expander.class"/>
847 <xsl:if test="$if != 'true'">
848 <xsl:text> if-if </xsl:text>
849 <xsl:value-of select="$if"/>
850 </xsl:if>
851 </xsl:with-param>
852 </xsl:call-template>
853 <xsl:call-template name="mal2html.ui.expander.data"/>
854 <div class="inner">
855 <xsl:apply-templates mode="mal2html.block.mode" select="mal:title[1]"/>
856 <div class="region">
857 <xsl:apply-templates mode="mal2html.block.mode" select="mal:desc[1]"/>
858 <div class="contents">
859 <xsl:for-each select="*[not(self::mal:title or self::mal:desc)]">
860 <xsl:apply-templates mode="mal2html.block.mode" select="."/>
861 </xsl:for-each>
862 </div>
863 </div>
864 </div>
865 </div>
866 </xsl:if>
867 </xsl:template>
868
869 <!-- = title = -->
870 <xsl:template mode="mal2html.block.mode" match="mal:title">
871 <xsl:param name="depth" select="count(ancestor::mal:section) + 2"/>
872 <xsl:variable name="depth_">
873 <xsl:choose>
874 <xsl:when test="$depth &lt; 6">
875 <xsl:value-of select="$depth"/>
876 </xsl:when>
877 <xsl:otherwise>
878 <xsl:value-of select="6"/>
879 </xsl:otherwise>
880 </xsl:choose>
881 </xsl:variable>
882 <xsl:variable name="style" select="concat(' ', @style, ' ')"/>
883 <div>
884 <xsl:call-template name="html.class.attr">
885 <xsl:with-param name="class">
886 <xsl:text>title title-</xsl:text>
887 <xsl:value-of select="local-name(..)"/>
888 <xsl:if test="contains($style, ' heading ')">
889 <xsl:text> title-heading</xsl:text>
890 </xsl:if>
891 <xsl:if test="contains($style, ' center ')">
892 <xsl:text> center</xsl:text>
893 </xsl:if>
894 </xsl:with-param>
895 </xsl:call-template>
896 <xsl:call-template name="html.lang.attrs"/>
897 <xsl:element name="{concat('h', $depth_)}" namespace="{$html.namespace}">
898 <span class="title">
899 <xsl:apply-templates mode="mal2html.inline.mode"/>
900 </span>
901 </xsl:element>
902 </div>
903 </xsl:template>
904
905 <!-- = if:choose = -->
906 <xsl:template mode="mal2html.block.mode" match="if:choose">
907 <xsl:apply-templates mode="_mal2html.choose.mode" select="if:when[1]"/>
908 </xsl:template>
909
910 <!-- = if:if = -->
911 <xsl:template mode="mal2html.block.mode" match="if:if">
912 <xsl:variable name="if">
913 <xsl:call-template name="mal.if.test"/>
914 </xsl:variable>
915 <xsl:if test="$if != ''">
916 <xsl:choose>
917 <xsl:when test="$if != 'true'">
918 <div class="if-if {$if}">
919 <xsl:apply-templates mode="mal2html.block.mode"/>
920 </div>
921 </xsl:when>
922 <xsl:otherwise>
923 <xsl:apply-templates mode="mal2html.block.mode"/>
924 </xsl:otherwise>
925 </xsl:choose>
926 </xsl:if>
927 </xsl:template>
928
929 <!--#% _mal2html.choose.mode -->
930 <xsl:template mode="_mal2html.choose.mode" match="if:when">
931 <xsl:variable name="if">
932 <xsl:call-template name="mal.if.test"/>
933 </xsl:variable>
934 <xsl:choose>
935 <xsl:when test="$if = 'true'">
936 <xsl:apply-templates mode="mal2html.block.mode"/>
937 </xsl:when>
938 <xsl:when test="$if != ''">
939 <div class="if-choose {$if}">
940 <div class="if-when">
941 <xsl:apply-templates mode="mal2html.block.mode"/>
942 </div>
943 <div class="if-else">
944 <xsl:apply-templates mode="_mal2html.choose.mode" select="following-sibling::*[1]"/>
945 </div>
946 </div>
947 </xsl:when>
948 <xsl:otherwise>
949 <xsl:apply-templates mode="_mal2html.choose.mode" select="following-sibling::*[1]"/>
950 </xsl:otherwise>
951 </xsl:choose>
952 </xsl:template>
953
954 <xsl:template mode="_mal2html.choose.mode" match="if:else">
955 <xsl:apply-templates mode="mal2html.block.mode"/>
956 </xsl:template>
957
958 <xsl:template mode="_mal2html.choose.mode" match="*">
959 <xsl:apply-templates mode="mal2html.block.mode" select=". | following-sibling::*"/>
960 </xsl:template>
961
962 </xsl:stylesheet>