fixed expressions and page tag arguments and with embedded
newlines in CRLF templates. follow up to #16.
thanks Eric Woroshow
diff --git a/CHANGES b/CHANGES
index 59b6027..8ffd937 100644
--- a/CHANGES
+++ b/CHANGES
@@ -4,6 +4,9 @@
 - comments can be placed at the end of control lines,
 i.e. if foo: # a comment, [ticket:53], thanks to 
 Paul Colomiets
+- fixed expressions and page tag arguments and with embedded
+newlines in CRLF templates, follow up to [ticket:16], thanks
+Eric Woroshow
 
 0.1.8
 - variable names declared in render methods by internal 
diff --git a/lib/mako/lexer.py b/lib/mako/lexer.py
index af85da0..36fe342 100644
--- a/lib/mako/lexer.py
+++ b/lib/mako/lexer.py
@@ -202,7 +202,9 @@
             if attr:
                 for att in re.findall(r"\s*(\w+)\s*=\s*(?:'([^']*)'|\"([^\"]*)\")", attr):
                     (key, val1, val2) = att
-                    attributes[key] = self.escape_code(val1 or val2)
+                    text = val1 or val2
+                    text = text.replace('\r\n', '\n')
+                    attributes[key] = self.escape_code(text)
             self.append_node(parsetree.Tag, keyword, attributes)
             if isend:
                 self.tag.pop()
@@ -285,6 +287,7 @@
                 (escapes, end) = self.parse_until_text(r'}')
             else:
                 escapes = ""
+            text = text.replace('\r\n', '\n')
             self.append_node(parsetree.Expression, self.escape_code(text), escapes.strip(), lineno=line, pos=pos)
             return True
         else:
diff --git a/test/lexer.py b/test/lexer.py
index a8fbb8a..0453438 100644
--- a/test/lexer.py
+++ b/test/lexer.py
@@ -395,8 +395,8 @@
     def test_crlf(self):
         template = file("./test_htdocs/crlf.html").read()
         nodes = Lexer(template).parse()
-        assert repr(nodes) == r"""TemplateNode({}, [Text(u'<html>\r\n\r\n', (1, 1)), PageTag(u'page', {}, (3, 1), []), Text(u'\r\n\r\nlike the name says.\r\n\r\n', (3, 9)), ControlLine(u'for', u'for x in [1,2,3]:', False, (7, 1)), Text(u'        ', (8, 1)), Expression(u'x', [], (8, 9)), Text(u'', (8, 13)), ControlLine(u'for', u'endfor', True, (9, 1)), Text(u'\r\n', (10, 1)), DefTag(u'def', {u'name': u'hi()'}, (11, 1), ["Text(u'\\r\\n    hi!\\r\\n', (11, 19))"]), Text(u'\r\n\r\n</html>', (13, 8))])"""
-        assert flatten_result(Template(template).render()) == """<html> like the name says. 1 2 3 </html>"""
+        assert repr(nodes) == r"""TemplateNode({}, [Text(u'<html>\r\n\r\n', (1, 1)), PageTag(u'page', {u'args': u"a=['foo',\n                'bar']"}, (3, 1), []), Text(u'\r\n\r\nlike the name says.\r\n\r\n', (4, 26)), ControlLine(u'for', u'for x in [1,2,3]:', False, (8, 1)), Text(u'        ', (9, 1)), Expression(u'x', [], (9, 9)), Text(u'', (9, 13)), ControlLine(u'for', u'endfor', True, (10, 1)), Text(u'\r\n', (11, 1)), Expression(u"trumpeter == 'Miles' and trumpeter or \\\n      'Dizzy'", [], (12, 1)), Text(u'\r\n\r\n', (13, 15)), DefTag(u'def', {u'name': u'hi()'}, (15, 1), ["Text(u'\\r\\n    hi!\\r\\n', (15, 19))"]), Text(u'\r\n\r\n</html>\r\n', (17, 8))])"""
+        assert flatten_result(Template(template).render()) == """<html> like the name says. 1 2 3 Dizzy </html>"""
     
     def test_comments(self):
         template = """
diff --git a/test_htdocs/crlf.html b/test_htdocs/crlf.html
index 4507f41..d2620db 100644
--- a/test_htdocs/crlf.html
+++ b/test_htdocs/crlf.html
@@ -1,6 +1,7 @@
 <html>

 

-<%page/>

+<%page args="a=['foo',

+                'bar']"/>

 

 like the name says.

 

@@ -8,8 +9,11 @@
         ${x}\

     % endfor

 

+${trumpeter == 'Miles' and trumpeter or \

+      'Dizzy'}

+

 <%def name="hi()">

     hi!

 </%def>

 

-</html>
\ No newline at end of file
+</html>