Skip to content

Commit

Permalink
Added test for the new 'smart_substitutions' feature of Smarty extens…
Browse files Browse the repository at this point in the history
…ion.
  • Loading branch information
MartinAltmayer committed Aug 14, 2014
1 parent 927ad00 commit e90687e
Showing 1 changed file with 33 additions and 0 deletions.
33 changes: 33 additions & 0 deletions tests/test_extensions.py
Original file line number Diff line number Diff line change
Expand Up @@ -583,3 +583,36 @@ def testNoMarker(self):
'</li>\n'
'</ul>\n'
'</div>\n')


class TestSmarty(unittest.TestCase):
def setUp(self):
config = {
'smarty': [
('smart_angled_quotes', True),
('smart_substitutions', {
'ndash': '\u2013',
'mdash': '\u2014',
'ellipsis': '\u2026',
'left-single-quote': '&sbquo;', # sb is not a typo!
'right-single-quote': '&lsquo;',
'left-double-quote': '&bdquo;',
'right-double-quote': '&ldquo;',
'left-angle-quote': '[',
'right-angle-quote': ']',
}),]
}
self.md = markdown.Markdown(extensions=['smarty'],
extension_configs=config)

def testCustomSubstitutions(self):
text = \
"""<< The "Unicode char of the year 2014"
is the 'mdash': ---
Must not be confused with 'ndash' (--) ... >>
"""
correct = \
"""<p>[ The &bdquo;Unicode char of the year 2014&ldquo;
is the &sbquo;mdash&lsquo;: \u2014
Must not be confused with &sbquo;ndash&lsquo; (\u2013) \u2026 ]</p>"""
self.assertEqual(self.md.convert(text), correct)

0 comments on commit e90687e

Please sign in to comment.