From b32cba5558d964f3445f20bdd44af8ed1cc2df83 Mon Sep 17 00:00:00 2001 From: Waylan Limberg Date: Thu, 4 Nov 2010 20:51:24 -0400 Subject: Fixed Ticket 74. AtomicStrings should now be ackowledged (and preserved) in all instances. This was a real pain to debug, but an easy fix once I found it. Thanks to obs for the report. --- tests/test_apis.py | 45 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) (limited to 'tests') diff --git a/tests/test_apis.py b/tests/test_apis.py index 0de4727..ebbc24f 100644 --- a/tests/test_apis.py +++ b/tests/test_apis.py @@ -325,3 +325,48 @@ class testETreeComments(unittest.TestCase): pretty.run(self.comment) self.assertEqual(markdown.html4.to_html_string(self.comment), '\n') + + +class testAtomicString(unittest.TestCase): + """ Test that AtomicStrings are honored (not parsed). """ + + def setUp(self): + md = markdown.Markdown() + self.inlineprocessor = md.treeprocessors['inline'] + + def testString(self): + """ Test that a regular string is parsed. """ + tree = markdown.util.etree.Element('div') + p = markdown.util.etree.SubElement(tree, 'p') + p.text = u'some *text*' + new = self.inlineprocessor.run(tree) + self.assertEqual(markdown.html4.to_html_string(new), + '

some text

') + + def testSimpleAtomicString(self): + """ Test that a simple AtomicString is not parsed. """ + tree = markdown.util.etree.Element('div') + p = markdown.util.etree.SubElement(tree, 'p') + p.text = markdown.util.AtomicString(u'some *text*') + new = self.inlineprocessor.run(tree) + self.assertEqual(markdown.html4.to_html_string(new), + '

some *text*

') + + def testNestedAtomicString(self): + """ Test that a nested AtomicString is not parsed. """ + tree = markdown.util.etree.Element('div') + p = markdown.util.etree.SubElement(tree, 'p') + p.text = markdown.util.AtomicString(u'*some* ') + span1 = markdown.util.etree.SubElement(p, 'span') + span1.text = markdown.util.AtomicString(u'*more* ') + span2 = markdown.util.etree.SubElement(span1, 'span') + span2.text = markdown.util.AtomicString(u'*text* ') + span3 = markdown.util.etree.SubElement(span2, 'span') + span3.text = markdown.util.AtomicString(u'*here*') + span3.tail = markdown.util.AtomicString(u' *to*') + span2.tail = markdown.util.AtomicString(u' *test*') + span1.tail = markdown.util.AtomicString(u' *with*') + new = self.inlineprocessor.run(tree) + self.assertEqual(markdown.html4.to_html_string(new), + '

*some* *more* *text* *here* *to* *test* *with*

') + -- cgit v1.2.3