Mercurial > genshi > genshi-test
changeset 158:8e81177059f3
* Add test case for SVG content embedded in an HTML document.
* The XHTML serializer now assumes that elements in a foreign namespace (such as SVG or MathML) can be serialized as empty tags (`<foo />`).
author | cmlenz |
---|---|
date | Wed, 16 Aug 2006 21:29:48 +0000 |
parents | 40fc3d36f5b4 |
children | 03a0cca25cf6 |
files | markup/output.py markup/tests/output.py markup/tests/template.py |
diffstat | 3 files changed, 26 insertions(+), 13 deletions(-) [+] |
line wrap: on
line diff
--- a/markup/output.py +++ b/markup/output.py @@ -231,7 +231,7 @@ buf += [' ', attrname, '="', escape(value), '"'] ns_attrib = [] - if (not tag.namespace or tag in namespace) and \ + if (tag.namespace and tag not in namespace) or \ tagname in empty_elems: kind, data, pos = stream.next() if kind is END:
--- a/markup/tests/output.py +++ b/markup/tests/output.py @@ -108,6 +108,19 @@ output = XML(text).render(XHTMLSerializer) self.assertEqual(text, output) + def test_embedded_svg(self): + text = """<html xmlns="http://www.w3.org/1999/xhtml" xmlns:svg="http://www.w3.org/2000/svg"> + <body> + <button> + <svg:svg width="600px" height="400px"> + <svg:polygon points="50,50 50,300 300,300" /> + </svg:svg> + </button> + </body> + </html>""" + output = XML(text).render(XHTMLSerializer) + self.assertEqual(text, output) + class HTMLSerializerTestCase(unittest.TestCase):
--- a/markup/tests/template.py +++ b/markup/tests/template.py @@ -647,16 +647,16 @@ file2 = open(os.path.join(self.dirname, 'tmpl2.html'), 'w') try: file2.write("""<html xmlns:xi="http://www.w3.org/2001/XInclude"> - <xi:include href="tmpl1.html" /> -</html>""") + <xi:include href="tmpl1.html" /> + </html>""") finally: file2.close() loader = TemplateLoader([self.dirname]) tmpl = loader.load('tmpl2.html') self.assertEqual("""<html> - <div>Included</div> -</html>""", tmpl.generate().render()) + <div>Included</div> + </html>""", tmpl.generate().render()) def test_relative_include_subdir(self): os.mkdir(os.path.join(self.dirname, 'sub')) @@ -669,16 +669,16 @@ file2 = open(os.path.join(self.dirname, 'tmpl2.html'), 'w') try: file2.write("""<html xmlns:xi="http://www.w3.org/2001/XInclude"> - <xi:include href="sub/tmpl1.html" /> -</html>""") + <xi:include href="sub/tmpl1.html" /> + </html>""") finally: file2.close() loader = TemplateLoader([self.dirname]) tmpl = loader.load('tmpl2.html') self.assertEqual("""<html> - <div>Included</div> -</html>""", tmpl.generate().render()) + <div>Included</div> + </html>""", tmpl.generate().render()) def test_relative_include_parentdir(self): file1 = open(os.path.join(self.dirname, 'tmpl1.html'), 'w') @@ -691,16 +691,16 @@ file2 = open(os.path.join(self.dirname, 'sub', 'tmpl2.html'), 'w') try: file2.write("""<html xmlns:xi="http://www.w3.org/2001/XInclude"> - <xi:include href="../tmpl1.html" /> -</html>""") + <xi:include href="../tmpl1.html" /> + </html>""") finally: file2.close() loader = TemplateLoader([self.dirname]) tmpl = loader.load('sub/tmpl2.html') self.assertEqual("""<html> - <div>Included</div> -</html>""", tmpl.generate().render()) + <div>Included</div> + </html>""", tmpl.generate().render()) def suite():