[51] | 1 | <?xml version="1.0" encoding="UTF-8"?> |
---|
[61] | 2 | <!-- |
---|
| 3 | XML Web generátor – program na generování webových stránek |
---|
| 4 | Copyright © 2012 František Kučera (frantovo.cz) |
---|
| 5 | |
---|
| 6 | This program is free software: you can redistribute it and/or modify |
---|
| 7 | it under the terms of the GNU General Public License as published by |
---|
[136] | 8 | the Free Software Foundation, version 3 of the License. |
---|
[61] | 9 | |
---|
| 10 | This program is distributed in the hope that it will be useful, |
---|
| 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
| 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
| 13 | GNU General Public License for more details. |
---|
| 14 | |
---|
| 15 | You should have received a copy of the GNU General Public License |
---|
| 16 | along with this program. If not, see <http://www.gnu.org/licenses/>. |
---|
| 17 | --> |
---|
[51] | 18 | <xsl:stylesheet version="2.0" |
---|
| 19 | xmlns="http://www.w3.org/1999/xhtml" |
---|
| 20 | xmlns:m="https://trac.frantovo.cz/xml-web-generator/wiki/xmlns/makro" |
---|
[76] | 21 | xmlns:j="java:cz.frantovo.xmlWebGenerator.makra.Pre" |
---|
[51] | 22 | xmlns:xsl="http://www.w3.org/1999/XSL/Transform" |
---|
| 23 | exclude-result-prefixes="m j"> |
---|
| 24 | |
---|
[87] | 25 | <!-- |
---|
| 26 | Zvýraznění syntaxe zdrojového kódu |
---|
| 27 | ********************************** |
---|
| 28 | Ukázky zdrojového kódu budou mít zvýrazněnou syntaxi pro větší přehlednost. |
---|
| 29 | * |
---|
| 30 | @jazyk programovací jazyk, ve kterém je daný zdrojový kód |
---|
| 31 | @src zdrojový kód nemusí být uvnitř elementu, ale můžeme se odkázat na externí soubor |
---|
| 32 | @odkaz nastavíme hodnotu „ano“, pokud chceme vložit odkaz na soubor je stažení |
---|
| 33 | --> |
---|
| 34 | <xsl:template match="m:pre"> |
---|
[112] | 35 | <xsl:variable name="zadání"> |
---|
| 36 | <xsl:apply-templates select="*|text()"/> |
---|
| 37 | </xsl:variable> |
---|
[87] | 38 | <xsl:call-template name="zvýrazniZdroják"> |
---|
[112] | 39 | <xsl:with-param name="zdroják" select="$zadání/text()"/> |
---|
[87] | 40 | </xsl:call-template> |
---|
| 41 | </xsl:template> |
---|
| 42 | |
---|
| 43 | <xsl:template match="m:pre[@src]"> |
---|
| 44 | <xsl:call-template name="zvýrazniZdroják"> |
---|
| 45 | <xsl:with-param name="zdroják" select="m:načti-textový-soubor(@src)"/> |
---|
| 46 | </xsl:call-template> |
---|
[51] | 47 | <xsl:if test="@odkaz = 'ano'"> |
---|
| 48 | <p class="zdroják-ke-stažení"> |
---|
| 49 | <span>Stáhnout: <a href="{encode-for-uri(@src)}"><xsl:value-of select="@src"/></a></span> |
---|
| 50 | </p> |
---|
| 51 | </xsl:if> |
---|
[87] | 52 | </xsl:template> |
---|
| 53 | |
---|
| 54 | <xsl:template name="zvýrazniZdroják"> |
---|
| 55 | <xsl:param name="zdroják"/> |
---|
| 56 | <xsl:variable name="zvýrazněnýZdroják" select="j:zvýrazniSyntaxi($zdroják, @jazyk)"/> |
---|
| 57 | <xsl:choose> |
---|
| 58 | <xsl:when test="$zvýrazněnýZdroják"> |
---|
| 59 | <xsl:comment>Následující kód je v jazyce <xsl:value-of select="@jazyk"/></xsl:comment> |
---|
| 60 | <xsl:value-of disable-output-escaping="yes" select="$zvýrazněnýZdroják"/> |
---|
| 61 | </xsl:when> |
---|
| 62 | <xsl:otherwise> |
---|
| 63 | <xsl:message>Zvýraznění syntaxe se nezdařilo → bude vložen původní nezvýrazněný kód.</xsl:message> |
---|
| 64 | <pre><xsl:value-of select="$zdroják"/></pre> |
---|
| 65 | </xsl:otherwise> |
---|
| 66 | </xsl:choose> |
---|
| 67 | </xsl:template> |
---|
[51] | 68 | |
---|
| 69 | </xsl:stylesheet> |
---|
[87] | 70 | |
---|