changeset 521:dc8646e2e918 stable-0.4.x

Ported [624] to 0.4.x branch.
author cmlenz
date Wed, 13 Jun 2007 12:39:10 +0000
parents e57be40ff6c3
children d3e5fe934d6e
files ChangeLog genshi/template/markup.py genshi/template/tests/markup.py
diffstat 3 files changed, 14 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog
+++ b/ChangeLog
@@ -7,6 +7,8 @@
  * The I18n filter was not replacing the original attributes with the
    translation, but instead adding a second attribute with the same name.
  * `TextTemplate` can now handle unicode source (ticket #125).
+ * A `<?python ?>` processing instruction containing trailing whitespace no
+   longer causes a syntax error (ticket #127).
 
 
 Version 0.4.1
--- a/genshi/template/markup.py
+++ b/genshi/template/markup.py
@@ -194,7 +194,7 @@
                     # number quite right
                     lines = [line.expandtabs() for line in data[1].splitlines()]
                     first = lines[0]
-                    rest = dedent('\n'.join(lines[1:]))
+                    rest = dedent('\n'.join(lines[1:])).rstrip()
                     if first.rstrip().endswith(':') and not rest[0].isspace():
                         rest = '\n'.join(['    ' + line for line
                                           in rest.splitlines()])
--- a/genshi/template/tests/markup.py
+++ b/genshi/template/tests/markup.py
@@ -195,6 +195,17 @@
           \xf6
         </div>""", unicode(tmpl.generate()))
 
+    def test_exec_with_trailing_space(self):
+        """
+        Verify that a code block processing instruction with trailing space
+        does not cause a syntax error (see ticket #127).
+        """
+        MarkupTemplate(u"""<foo>
+          <?python
+            bar = 42
+          ?>
+        </foo>""")
+
     def test_exec_import(self):
         tmpl = MarkupTemplate(u"""<?python from datetime import timedelta ?>
         <div xmlns:py="http://genshi.edgewall.org/">
Copyright (C) 2012-2017 Edgewall Software