diff options
author | Dmitry Shachnev <mitya57@gmail.com> | 2015-03-18 22:36:57 +0300 |
---|---|---|
committer | Dmitry Shachnev <mitya57@gmail.com> | 2015-03-18 22:40:57 +0300 |
commit | cf7234dea91637de77179bf6e00c66e15c06f070 (patch) | |
tree | e50033034b6ef5a1ec007313e7d127835cd8ad30 | |
parent | 04479ee7a6c3a6f1efe9410202cc5c2d467385ee (diff) | |
download | markdown-cf7234dea91637de77179bf6e00c66e15c06f070.tar.gz markdown-cf7234dea91637de77179bf6e00c66e15c06f070.tar.bz2 markdown-cf7234dea91637de77179bf6e00c66e15c06f070.zip |
smarty: Add back special case for decade abbreviations
The previous version did not work, and was incorrectly removed as part of
85ad18071d619251. In the new version, use lookbehind search for \w instead
of \b, so that it works.
Update the tests accordingly.
Fixes #399 (except parts that we can't fix). Thanks @gandaro for the report.
-rw-r--r-- | markdown/extensions/smarty.py | 4 | ||||
-rw-r--r-- | tests/extensions/smarty.html | 10 | ||||
-rw-r--r-- | tests/extensions/smarty.txt | 2 |
3 files changed, 10 insertions, 6 deletions
diff --git a/markdown/extensions/smarty.py b/markdown/extensions/smarty.py index 3d79061..46e54c1 100644 --- a/markdown/extensions/smarty.py +++ b/markdown/extensions/smarty.py @@ -126,6 +126,9 @@ doubleQuoteStartRe = r'^"(?=%s\B)' % punctClass doubleQuoteSetsRe = r""""'(?=\w)""" singleQuoteSetsRe = r"""'"(?=\w)""" +# Special case for decade abbreviations (the '80s): +decadeAbbrRe = r"(?<!\w)'(?=\d{2}s)" + # Get most opening double quotes: openingDoubleQuotesRegex = r'%s"(?=\w)' % openingQuotesBase @@ -227,6 +230,7 @@ class SmartyExtension(Extension): (doubleQuoteStartRe, (rdquo,)), (doubleQuoteSetsRe, (ldquo + lsquo,)), (singleQuoteSetsRe, (lsquo + ldquo,)), + (decadeAbbrRe, (rsquo,)), (openingSingleQuotesRegex, (2, lsquo)), (closingSingleQuotesRegex, (rsquo,)), (closingSingleQuotesRegex2, (rsquo, 2)), diff --git a/tests/extensions/smarty.html b/tests/extensions/smarty.html index 6305060..d41e467 100644 --- a/tests/extensions/smarty.html +++ b/tests/extensions/smarty.html @@ -1,11 +1,11 @@ -<p>’. +<p>’.<br /> 1440–80’s<br /> -1440–‘80s<br /> -1440—‘80s<br /> +1440–’80s<br /> +1440—’80s<br /> 1960s<br /> 1960’s<br /> -one two ‘60s<br /> -‘60s</p> +one two ’60s<br /> +’60s</p> <p>It’s fun. What’s fun?<br /> “Isn’t this fun”? — she said…<br /> “‘Quoted’ words in a larger quote.”<br /> diff --git a/tests/extensions/smarty.txt b/tests/extensions/smarty.txt index 35fb219..48430bb 100644 --- a/tests/extensions/smarty.txt +++ b/tests/extensions/smarty.txt @@ -1,4 +1,4 @@ -'. +'. 1440--80's 1440--'80s 1440---'80s |