# HG changeset patch # User cmlenz # Date 1164228515 0 # Node ID 4f431931d64e85cd58b92b928cf05b1dc40348c5 # Parent 7dabedbb53fbf2533c932b6b5d5b91dc8c62f6a4 Fix for #62: preserve whitespace in front of directives. diff --git a/ChangeLog b/ChangeLog --- a/ChangeLog +++ b/ChangeLog @@ -30,8 +30,17 @@ are callable. * Instances of the `genshi.core.Attrs` class are now immutable (they are subclasses of `tuple` instead of `list`). - * Preserve whitespace in HTML `
` elements also when they contained any
-   child elements.
+
+
+Version 0.3.5
+http://svn.edgewall.org/repos/genshi/tags/0.3.4/
+(Nov 22 2006, from branches/stable/0.3.x)
+
+ * Preserve whitespace in HTML `
` elements also when they contain child
+   elements.
+ * Match templates no longer match their own output (ticket #77).
+ * Blank lines before directives in text templates are now preserved as
+   expected (ticket #62).
 
 
 Version 0.3.4
diff --git a/genshi/template/tests/directives.py b/genshi/template/tests/directives.py
--- a/genshi/template/tests/directives.py
+++ b/genshi/template/tests/directives.py
@@ -380,7 +380,8 @@
           #end
           ${echo('Hi', name='you')}
         """)
-        self.assertEqual("""                      Hi, you!
+        self.assertEqual("""
+                      Hi, you!
         """, str(tmpl.generate()))
 
 
diff --git a/genshi/template/tests/text.py b/genshi/template/tests/text.py
--- a/genshi/template/tests/text.py
+++ b/genshi/template/tests/text.py
@@ -37,26 +37,42 @@
         #if foo
           bar
         #end 'if foo'""")
-        self.assertEqual('', str(tmpl.generate()))
+        self.assertEqual('\n', str(tmpl.generate()))
 
     def test_latin1_encoded(self):
         text = u'$foo\xf6$bar'.encode('iso-8859-1')
         tmpl = TextTemplate(text, encoding='iso-8859-1')
         self.assertEqual(u'x\xf6y', unicode(tmpl.generate(foo='x', bar='y')))
 
-    # FIXME
-    #def test_empty_lines(self):
-    #    tmpl = TextTemplate("""Your items:
-    #
-    #    #for item in items
-    #      * ${item}
-    #
-    #    #end""")
-    #    self.assertEqual("""Your items:
-    #      * 0
-    #      * 1
-    #      * 2
-    #    """, tmpl.generate(items=range(3)).render('text'))
+    def test_empty_lines1(self):
+        tmpl = TextTemplate("""Your items:
+
+        #for item in items
+          * ${item}
+        #end""")
+        self.assertEqual("""Your items:
+
+          * 0
+          * 1
+          * 2
+""", tmpl.generate(items=range(3)).render('text'))
+
+    def test_empty_lines2(self):
+        tmpl = TextTemplate("""Your items:
+
+        #for item in items
+          * ${item}
+
+        #end""")
+        self.assertEqual("""Your items:
+
+          * 0
+
+          * 1
+
+          * 2
+
+""", tmpl.generate(items=range(3)).render('text'))
 
 
 def suite():
diff --git a/genshi/template/text.py b/genshi/template/text.py
--- a/genshi/template/text.py
+++ b/genshi/template/text.py
@@ -50,7 +50,9 @@
                   ('choose', ChooseDirective),
                   ('with', WithDirective)]
 
-    _DIRECTIVE_RE = re.compile(r'^\s*(?