Mercurial > genshi > genshi-test
comparison markup/tests/output.py @ 143:ef761afcedff
CDATA sections in XML input now appear as CDATA sections in the output. This should address the problem with escaping the contents of `<style>` and `<script>` elements, which would only get interpreted correctly if the output was served as `application/xhtml+xml`. Closes #24.
author | cmlenz |
---|---|
date | Fri, 11 Aug 2006 14:08:13 +0000 |
parents | b3ceaa35fb6b |
children | 8e81177059f3 |
comparison
equal
deleted
inserted
replaced
142:b49cc51999b9 | 143:ef761afcedff |
---|---|
93 text = '<foo xml:space="preserve"> Do not mess \n\n with me </foo>' | 93 text = '<foo xml:space="preserve"> Do not mess \n\n with me </foo>' |
94 output = XML(text).render(XHTMLSerializer) | 94 output = XML(text).render(XHTMLSerializer) |
95 self.assertEqual(text, output) | 95 self.assertEqual(text, output) |
96 | 96 |
97 def test_script_escaping(self): | 97 def test_script_escaping(self): |
98 text = '<script><![CDATA[if (1 < 2) { alert("Doh"); }]]></script>' | 98 text = """<script>/*<![CDATA[*/ |
99 if (1 < 2) { alert("Doh"); } | |
100 /*]]>*/</script>""" | |
99 output = XML(text).render(XHTMLSerializer) | 101 output = XML(text).render(XHTMLSerializer) |
100 self.assertEqual('<script>if (1 < 2) { alert("Doh"); }</script>', | 102 self.assertEqual(text, output) |
101 output) | |
102 | 103 |
103 def test_style_escaping(self): | 104 def test_style_escaping(self): |
104 text = '<style><![CDATA[html > body { display: none; }]]></style>' | 105 text = """<style>/*<![CDATA[*/ |
106 html > body { display: none; } | |
107 /*]]>*/</style>""" | |
105 output = XML(text).render(XHTMLSerializer) | 108 output = XML(text).render(XHTMLSerializer) |
106 self.assertEqual('<style>html > body { display: none; }</style>', | 109 self.assertEqual(text, output) |
107 output) | |
108 | 110 |
109 | 111 |
110 class HTMLSerializerTestCase(unittest.TestCase): | 112 class HTMLSerializerTestCase(unittest.TestCase): |
111 | 113 |
112 def test_xml_space(self): | 114 def test_xml_space(self): |