# HG changeset patch
# User František Kučera <franta-hg@frantovo.cz>
# Date 1318599414 -7200
# Node ID 245311d1072632b0100431b00d630bc70f358ed3
# Parent  969f001a0f5fbc6506ea3cef7568fecfd41cac30
Drupal: XSLT odstavce – vnořující se.

diff -r 969f001a0f5f -r 245311d10726 helpers/mimeXhtmlPart.xsl
--- a/helpers/mimeXhtmlPart.xsl	Fri Oct 14 13:32:34 2011 +0200
+++ b/helpers/mimeXhtmlPart.xsl	Fri Oct 14 15:36:54 2011 +0200
@@ -155,40 +155,80 @@
 	<xsl:template name="zpracujTělo">
 		<xsl:param name="prvek"/>
 		<xsl:if test="$prvek">
-			<li>
-				&lt;
-				<xsl:choose>
-					<xsl:when test="$prvek/self::text()">
-						<!--
-							Textový uzel → budeme dělat odstavce
-							(rekurzivně se opět zavolá šablona zpracujTělo)
-						<xsl:call-template name="dělejOdstavce">
-							<xsl:with-param name="blokTextu" select="."/>
-						</xsl:call-template>
-						-->
-						[T]
-					</xsl:when>
-					<xsl:otherwise>
-						<!--
-							Jiný uzel → aplikujeme obecné šablony
-							a zpracujeme následující uzel.
-						<xsl:apply-templates select="."/>
-						-->
-						[N]
-					</xsl:otherwise>					
-				</xsl:choose>
-				[<xsl:value-of select="$prvek/name()"/>]
-				[<xsl:value-of select="$prvek/text()"/>]
-				[<xsl:value-of select="$prvek/self::text()"/>]
-				&gt;
-			</li>	
-			<xsl:call-template name="zpracujTělo">
-					<xsl:with-param name="prvek" select="$prvek/following-sibling::node()[1]"/>
-			</xsl:call-template>
-				
+			<xsl:choose>
+				<xsl:when test="$prvek/self::text()">
+					<!--
+						Textový uzel → budeme dělat odstavce
+						(rekurzivně se opět zavolá šablona zpracujTělo)
+					-->
+					<xsl:call-template name="dělejOdstavceX">
+						<xsl:with-param name="blokTextu" select="$prvek"/>
+					</xsl:call-template>
+				</xsl:when>
+				<xsl:otherwise>
+					<!--
+						Jiný uzel → aplikujeme obecné šablony
+						a zpracujeme následující uzel.
+					-->
+					<xsl:apply-templates select="$prvek"/>
+					<xsl:call-template name="zpracujTělo">
+						<xsl:with-param name="prvek" select="$prvek/following-sibling::node()[1]"/>
+					</xsl:call-template>
+				</xsl:otherwise>					
+			</xsl:choose>				
 		</xsl:if>
 	</xsl:template>
 	
+	<xsl:template name="dělejOdstavceX">
+		<xsl:param name="blokTextu"/>
+		<xsl:variable name="oddělovač" select="'\n\s+\n\s+'"/>
+		<xsl:variable name="dalšíUzel" select="$blokTextu/following-sibling::node()[1]"/>
+		
+		<xsl:variable name="navázat" select="
+				not(fn:matches($blokTextu, concat('.*', $oddělovač ,'$'))) and
+				$dalšíUzel and
+				not(
+					$dalšíUzel/name() = 'p' or
+					$dalšíUzel/name() = 'div' or								
+					$dalšíUzel/name() = 'h1' or								
+					$dalšíUzel/name() = 'h2' or								
+					$dalšíUzel/name() = 'h3' or								
+					$dalšíUzel/name() = 'h4' or								
+					$dalšíUzel/name() = 'h5' or								
+					$dalšíUzel/name() = 'h6' or								
+					$dalšíUzel/name() = 'pre' or								
+					$dalšíUzel/name() = 'table' or								
+					$dalšíUzel/name() = 'blockquote' or								
+					$dalšíUzel/name() = 'hr'								
+				)
+				"/>
+		
+		<xsl:for-each select="fn:tokenize($blokTextu, $oddělovač)">
+			<xsl:if test="normalize-space(.)">
+				<p class="mešuge">
+					<xsl:value-of select="."/>
+					<xsl:if test="$navázat and position() = last()">
+						<xsl:apply-templates select="$dalšíUzel"/>
+					</xsl:if>
+					<xsl:call-template name="zpracujTělo">
+						<xsl:with-param name="prvek" select="$dalšíUzel/following-sibling::node()[1]"/>
+					</xsl:call-template>
+				</p>
+			</xsl:if>
+		</xsl:for-each>
+		
+		<xsl:if test="not($navázat)">
+			<xsl:call-template name="zpracujTělo">
+				<xsl:with-param name="prvek" select="$dalšíUzel"/>
+			</xsl:call-template>
+		</xsl:if>
+	</xsl:template>
+	
+	
+	
+	
+	
+	
 	<xsl:template name="dělejOdstavce">
 		<xsl:param name="blokTextu"/>
 		<xsl:variable name="oddělovač" select="'\n\s+\n\s+'"/>
@@ -206,8 +246,7 @@
 						position() = last() and
 						not(fn:matches($blokTextu, concat('.*', $oddělovač ,'$')))
 						">
-						
-						<xsl:variable name="n" select="$blokTextu/following-sibling::*[position() = 1]"/>
+						<xsl:variable name="n" select="$blokTextu/following-sibling::*[1]"/>
 						<xsl:variable name="nn" select="$n/name()"/>
 						<!--
 							Za blokem textu nenásleduje značka, která nemůže být uvnitř odstavce.
@@ -227,10 +266,14 @@
 								$nn = 'hr'								
 							)">
 							<xsl:apply-templates select="$n"/>
-							<xsl:apply-templates select="$n/following-sibling::text()[position() = 1]"/>
-						</xsl:if>						
+						</xsl:if>
+						
+						<xsl:call-template name="zpracujTělo">
+							<xsl:with-param name="prvek" select="$blokTextu/following-sibling::node()[1]"/>
+						</xsl:call-template>
+				
 					</xsl:if>
-				</p>
+				</p>				
 			</xsl:if>
 		</xsl:for-each>
 	</xsl:template>