Example #1
0
 def test_script_escaping_with_namespace(self):
     text = """<script xmlns="http://www.w3.org/1999/xhtml">
         if (1 &lt; 2) { alert("Doh"); }
     </script>"""
     output = XML(text).render(HTMLSerializer)
     self.assertEqual("""<script>
         if (1 < 2) { alert("Doh"); }
     </script>""", output)
Example #2
0
 def test_empty_script(self):
     text = """<html xmlns="http://www.w3.org/1999/xhtml">
         <script src="foo.js" />
     </html>"""
     output = XML(text).render(XHTMLSerializer)
     self.assertEqual("""<html xmlns="http://www.w3.org/1999/xhtml">
         <script src="foo.js"></script>
     </html>""", output)
Example #3
0
 def test_style_escaping_with_namespace(self):
     text = """<style xmlns="http://www.w3.org/1999/xhtml">
         html &gt; body { display: none; }
     </style>"""
     output = XML(text).render(HTMLSerializer)
     self.assertEqual("""<style>
         html > body { display: none; }
     </style>""", output)
Example #4
0
 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 id="triangle" points="50,50 50,300 300,300"></svg:polygon>
           </svg:svg>
         </button>
       </body>
     </html>"""
     output = XML(text).render(XHTMLSerializer)
     self.assertEqual(text, output)
Example #5
0
 def test_atom_with_xhtml(self):
     text = """<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
         <id>urn:uuid:c60843aa-0da8-4fa6-bbe5-98007bc6774e</id>
         <updated>2007-01-28T11:36:02.807108-06:00</updated>
         <title type="xhtml">
             <div xmlns="http://www.w3.org/1999/xhtml">Example</div>
         </title>
         <subtitle type="xhtml">
             <div xmlns="http://www.w3.org/1999/xhtml">Bla bla bla</div>
         </subtitle>
         <icon/>
     </feed>"""
     output = XML(text).render(XMLSerializer)
     self.assertEqual(text, output)
Example #6
0
 def test_style_escaping(self):
     text = '<style>html &gt; body { display: none; }</style>'
     output = XML(text).render(HTMLSerializer)
     self.assertEqual('<style>html > body { display: none; }</style>',
                      output)
Example #7
0
 def test_script_escaping(self):
     text = '<script>if (1 &lt; 2) { alert("Doh"); }</script>'
     output = XML(text).render(HTMLSerializer)
     self.assertEqual('<script>if (1 < 2) { alert("Doh"); }</script>',
                      output)
Example #8
0
 def test_empty_script(self):
     text = '<script src="foo.js" />'
     output = XML(text).render(XHTMLSerializer)
     self.assertEqual('<script src="foo.js"></script>', output)
Example #9
0
 def test_xml_space(self):
     text = '<foo xml:space="preserve"> Do not mess  \n\n with me </foo>'
     output = XML(text).render(HTMLSerializer)
     self.assertEqual('<foo> Do not mess  \n\n with me </foo>', output)
Example #10
0
 def test_text_content(self):
     stream = XML('<elem>foo</elem>') | EmptyTagFilter()
     self.assertEqual([Stream.START, Stream.TEXT, Stream.END],
                      [ev[0] for ev in stream])
Example #11
0
 def test_xhtml_namespace_prefix(self):
     text = """<div xmlns="http://www.w3.org/1999/xhtml">
         <strong>Hello</strong>
     </div>"""
     output = XML(text).render(XHTMLSerializer)
     self.assertEqual(text, output)
Example #12
0
 def test_style_escaping_with_namespace(self):
     text = """<style xmlns="http://www.w3.org/1999/xhtml">/*<![CDATA[*/
         html > body { display: none; }
     /*]]>*/</style>"""
     output = XML(text).render(XHTMLSerializer)
     self.assertEqual(text, output)
Example #13
0
 def test_style_escaping(self):
     text = """<style>/*<![CDATA[*/
         html > body { display: none; }
     /*]]>*/</style>"""
     output = XML(text).render(XHTMLSerializer)
     self.assertEqual(text, output)
Example #14
0
 def test_script_escaping_with_namespace(self):
     text = """<script xmlns="http://www.w3.org/1999/xhtml">/*<![CDATA[*/
         if (1 < 2) { alert("Doh"); }
     /*]]>*/</script>"""
     output = XML(text).render(XHTMLSerializer)
     self.assertEqual(text, output)
Example #15
0
 def test_script_escaping(self):
     text = """<script>/*<![CDATA[*/
         if (1 < 2) { alert("Doh"); }
     /*]]>*/</script>"""
     output = XML(text).render(XHTMLSerializer)
     self.assertEqual(text, output)
Example #16
0
 def test_empty(self):
     stream = XML('<elem></elem>') | EmptyTagFilter()
     self.assertEqual([EmptyTagFilter.EMPTY], [ev[0] for ev in stream])
Example #17
0
 def test_textarea_whitespace(self):
     content = '\nHey there.  \n\n    I am indented.\n'
     stream = XML('<textarea name="foo">%s</textarea>' % content)
     output = stream.render(HTMLSerializer)
     self.assertEqual('<textarea name="foo">%s</textarea>' % content, output)
Example #18
0
 def test_elem_content(self):
     stream = XML('<elem><sub /><sub /></elem>') | EmptyTagFilter()
     self.assertEqual([Stream.START, EmptyTagFilter.EMPTY,
                       EmptyTagFilter.EMPTY, Stream.END],
                      [ev[0] for ev in stream])
Example #19
0
 def test_pre_whitespace(self):
     content = '\nHey <em>there</em>.  \n\n    I am indented.\n'
     stream = XML('<pre>%s</pre>' % content)
     output = stream.render(HTMLSerializer)
     self.assertEqual('<pre>%s</pre>' % content, output)