Test HTML serialization.
(self)
| 500 | """ Test the html and xhtml serializers. """ |
| 501 | |
| 502 | def testHtml(self): |
| 503 | """ Test HTML serialization. """ |
| 504 | el = etree.Element('div') |
| 505 | el.set('id', 'foo<&">') |
| 506 | p = etree.SubElement(el, 'p') |
| 507 | p.text = 'foo <&escaped>' |
| 508 | p.set('hidden', 'hidden') |
| 509 | etree.SubElement(el, 'hr') |
| 510 | non_element = etree.SubElement(el, None) |
| 511 | non_element.text = 'non-element text' |
| 512 | script = etree.SubElement(non_element, 'script') |
| 513 | script.text = '<&"test\nescaping">' |
| 514 | el.tail = "tail text" |
| 515 | self.assertEqual( |
| 516 | markdown.serializers.to_html_string(el), |
| 517 | '<div id="foo<&">">' |
| 518 | '<p hidden>foo <&escaped></p>' |
| 519 | '<hr>' |
| 520 | 'non-element text' |
| 521 | '<script><&"test\nescaping"></script>' |
| 522 | '</div>tail text' |
| 523 | ) |
| 524 | |
| 525 | def testXhtml(self): |
| 526 | """" Test XHTML serialization. """ |