Test HTML serialization.
(self)
| 524 | """ Test the html and xhtml serializers. """ |
| 525 | |
| 526 | def testHtml(self): |
| 527 | """ Test HTML serialization. """ |
| 528 | el = etree.Element('div') |
| 529 | el.set('id', 'foo<&">') |
| 530 | p = etree.SubElement(el, 'p') |
| 531 | p.text = 'foo <&escaped>' |
| 532 | p.set('hidden', 'hidden') |
| 533 | etree.SubElement(el, 'hr') |
| 534 | non_element = etree.SubElement(el, None) |
| 535 | non_element.text = 'non-element text' |
| 536 | script = etree.SubElement(non_element, 'script') |
| 537 | script.text = '<&"test\nescaping">' |
| 538 | el.tail = "tail text" |
| 539 | self.assertEqual( |
| 540 | markdown.serializers.to_html_string(el), |
| 541 | '<div id="foo<&">">' |
| 542 | '<p hidden>foo <&escaped></p>' |
| 543 | '<hr>' |
| 544 | 'non-element text' |
| 545 | '<script><&"test\nescaping"></script>' |
| 546 | '</div>tail text' |
| 547 | ) |
| 548 | |
| 549 | def testXhtml(self): |
| 550 | """" Test XHTML serialization. """ |