[yelp-xsl] [mal2html] Adding floatleft and floatright style for block media



commit 14d002509ce384adadbc28ce6fc0933d77b4411e
Author: Shaun McCance <shaunm gnome org>
Date:   Tue Jan 12 15:46:10 2010 -0600

    [mal2html] Adding floatleft and floatright style for block media

 xslt/mallard/html/mal2html-css.xsl   |   10 ++++++++++
 xslt/mallard/html/mal2html-media.xsl |   26 +++++++++++++++++---------
 2 files changed, 27 insertions(+), 9 deletions(-)
---
diff --git a/xslt/mallard/html/mal2html-css.xsl b/xslt/mallard/html/mal2html-css.xsl
index f1e016d..6553df1 100644
--- a/xslt/mallard/html/mal2html-css.xsl
+++ b/xslt/mallard/html/mal2html-css.xsl
@@ -107,6 +107,16 @@ body {
 ul, ol, dl, dd { margin: 0; }
 div, pre, p, li, dt { margin: 1em 0 0 0; padding: 0; }
 .first-child { margin-top: 0; }
+div.floatleft {
+  float: left;
+  margin-top: 0;
+  margin-right: 1em;
+}
+div.floatright {
+  float: right;
+  margin-top: 0;
+  margin-left: 1em;
+}
 li.condensed { margin-top: 0.2em; }
 a {
   text-decoration: none;
diff --git a/xslt/mallard/html/mal2html-media.xsl b/xslt/mallard/html/mal2html-media.xsl
index 66e6ac4..10d841b 100644
--- a/xslt/mallard/html/mal2html-media.xsl
+++ b/xslt/mallard/html/mal2html-media.xsl
@@ -114,14 +114,26 @@ FIXME
 <!-- = mal2html.block.mode % media = -->
 <xsl:template mode="mal2html.block.mode" match="mal:media">
   <xsl:param name="first_child" select="not(preceding-sibling::*)"/>
+  <xsl:variable name="style" select="concat(' ', @style, ' ')"/>
+  <xsl:variable name="class">
+    <xsl:choose>
+      <xsl:when test="contains($style, 'floatleft')">
+        <xsl:text> floatleft</xsl:text>
+      </xsl:when>
+      <xsl:when test="contains($style, 'floatright')">
+        <xsl:text> floatright</xsl:text>
+      </xsl:when>
+    </xsl:choose>
+    <xsl:if test="$first_child">
+      <xsl:text> first-child</xsl:text>
+    </xsl:if>
+  </xsl:variable>
   <xsl:choose>
     <xsl:when test="@type = 'image'">
       <div>
         <xsl:attribute name="class">
           <xsl:text>media media-image</xsl:text>
-          <xsl:if test="$first_child">
-            <xsl:text> first-child</xsl:text>
-          </xsl:if>
+          <xsl:value-of select="$class"/>
         </xsl:attribute>
         <xsl:call-template name="mal2html.media.image"/>
       </div>
@@ -130,9 +142,7 @@ FIXME
       <div>
         <xsl:attribute name="class">
           <xsl:text>media media-video</xsl:text>
-          <xsl:if test="$first_child">
-            <xsl:text> first-child</xsl:text>
-          </xsl:if>
+          <xsl:value-of select="$class"/>
         </xsl:attribute>
         <xsl:call-template name="mal2html.media.video"/>
       </div>
@@ -141,9 +151,7 @@ FIXME
       <div>
         <xsl:attribute name="class">
           <xsl:text>media media-audio</xsl:text>
-          <xsl:if test="$first_child">
-            <xsl:text> first-child</xsl:text>
-          </xsl:if>
+          <xsl:value-of select="$class"/>
         </xsl:attribute>
         <xsl:call-template name="mal2html.media.audio"/>
       </div>



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]