From 106db552c20c65c2b8bff3ef1ffd37e6a154a5a2 Mon Sep 17 00:00:00 2001 From: Yu-Jie Lin Date: Wed, 28 Aug 2013 16:02:41 +0800 Subject: fix --- being converted in educateDashes The original Perl smartypants.pl does not do such conversion. The ``---`` convsersion was added in v1.5_1.5 (eed4a8a16f11). --- CHANGES.rst | 7 +++++++ smartypants.py | 3 +-- tests/test.py | 2 +- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/CHANGES.rst b/CHANGES.rst index e47dab2..19ae366 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -17,6 +17,13 @@ development: - add ``doc`` for documentation generation - add ``upload_doc`` for uploading to PyPI - add ``clean`` for cleaning up built files + - fix ``---`` being converted in ``educateDashes`` + + The Perl doesn't do such, and it's possibly a mistaken in + version v1.5_1.5 (eed4a8a16f11). + + If you want the same behavior with default attributes, you need to use + ``Attr.q | Attr.b | Attr.i | Attr.e``. 1.8.1: 2013-08-20T02:27:35Z diff --git a/smartypants.py b/smartypants.py index 9e4d038..33e5e94 100755 --- a/smartypants.py +++ b/smartypants.py @@ -488,8 +488,7 @@ def educateDashes(text): Convert ``--`` in *text* into em-dash HTML entities. """ - text = re.sub('---', '–', text) # en (yes, backwards) - text = re.sub('--', '—', text) # em (yes, backwards) + text = re.sub('--', '—', text) return text diff --git a/tests/test.py b/tests/test.py index 549b19f..ffd20ac 100644 --- a/tests/test.py +++ b/tests/test.py @@ -35,7 +35,7 @@ class SmartyPantsTestCase(unittest.TestCase): self.assertEqual(sp("1440-80's"), "1440-80’s") self.assertEqual(sp("1440-'80s"), "1440-‘80s") - self.assertEqual(sp("1440---'80s"), "1440–‘80s") + self.assertEqual(sp("1440--'80s"), "1440—‘80s") self.assertEqual(sp("1960s"), "1960s") # no effect. self.assertEqual(sp("1960's"), "1960’s") self.assertEqual(sp("one two '60s"), "one two ‘60s") -- cgit v1.2.1