From a64592d5f288d0b83b11aa7d4eade728d5d5fb91 Mon Sep 17 00:00:00 2001 From: Waylan Limberg Date: Wed, 7 Aug 2013 21:39:08 -0400 Subject: Serializers now preserve case of tags. It is up to the markdown code (and extension authors to make sure tags are of the correct case (there may be cases were an extension might need to mix cases - which should be preserved). Fixes #237. Thanks for the report @eichin. --- tests/test_apis.py | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) (limited to 'tests') diff --git a/tests/test_apis.py b/tests/test_apis.py index dd232b3..4a7c7c7 100644 --- a/tests/test_apis.py +++ b/tests/test_apis.py @@ -326,6 +326,38 @@ class testETreeComments(unittest.TestCase): '\n') +class testSerializers(unittest.TestCase): + """ Test the html and xhtml serializers. """ + + def testHtml(self): + """ Test HTML serialization. """ + el = markdown.util.etree.Element('div') + p = markdown.util.etree.SubElement(el, 'p') + p.text = 'foo' + hr = markdown.util.etree.SubElement(el, 'hr') + self.assertEqual(markdown.serializers.to_html_string(el), + '

foo


') + + def testXhtml(self): + """" Test XHTML serialization. """ + el = markdown.util.etree.Element('div') + p = markdown.util.etree.SubElement(el, 'p') + p.text = 'foo' + hr = markdown.util.etree.SubElement(el, 'hr') + self.assertEqual(markdown.serializers.to_xhtml_string(el), + '

foo


') + + def testMixedCaseTags(self): + """" Test preservation of tag case. """ + el = markdown.util.etree.Element('MixedCase') + el.text = 'not valid ' + em = markdown.util.etree.SubElement(el, 'EMPHASIS') + em.text = 'html' + hr = markdown.util.etree.SubElement(el, 'HR') + self.assertEqual(markdown.serializers.to_xhtml_string(el), + 'not valid html
') + + class testAtomicString(unittest.TestCase): """ Test that AtomicStrings are honored (not parsed). """ -- cgit v1.2.3