Skip to content

Commit cf7234d

Browse files
committed
smarty: Add back special case for decade abbreviations
The previous version did not work, and was incorrectly removed as part of 85ad180. In the new version, use lookbehind search for \w instead of \b, so that it works. Update the tests accordingly. Fixes Python-Markdown#399 (except parts that we can't fix). Thanks @gandaro for the report.
1 parent 04479ee commit cf7234d

File tree

3 files changed

+10
-6
lines changed

3 files changed

+10
-6
lines changed

markdown/extensions/smarty.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,9 @@
126126
doubleQuoteSetsRe = r""""'(?=\w)"""
127127
singleQuoteSetsRe = r"""'"(?=\w)"""
128128

129+
# Special case for decade abbreviations (the '80s):
130+
decadeAbbrRe = r"(?<!\w)'(?=\d{2}s)"
131+
129132
# Get most opening double quotes:
130133
openingDoubleQuotesRegex = r'%s"(?=\w)' % openingQuotesBase
131134

@@ -227,6 +230,7 @@ def educateQuotes(self, md):
227230
(doubleQuoteStartRe, (rdquo,)),
228231
(doubleQuoteSetsRe, (ldquo + lsquo,)),
229232
(singleQuoteSetsRe, (lsquo + ldquo,)),
233+
(decadeAbbrRe, (rsquo,)),
230234
(openingSingleQuotesRegex, (2, lsquo)),
231235
(closingSingleQuotesRegex, (rsquo,)),
232236
(closingSingleQuotesRegex2, (rsquo, 2)),

tests/extensions/smarty.html

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
<p>&rsquo;.
1+
<p>&rsquo;.<br />
22
1440&ndash;80&rsquo;s<br />
3-
1440&ndash;&lsquo;80s<br />
4-
1440&mdash;&lsquo;80s<br />
3+
1440&ndash;&rsquo;80s<br />
4+
1440&mdash;&rsquo;80s<br />
55
1960s<br />
66
1960&rsquo;s<br />
7-
one two &lsquo;60s<br />
8-
&lsquo;60s</p>
7+
one two &rsquo;60s<br />
8+
&rsquo;60s</p>
99
<p>It&rsquo;s fun. What&rsquo;s fun?<br />
1010
&ldquo;Isn&rsquo;t this fun&rdquo;? &mdash; she said&hellip;<br />
1111
&ldquo;&lsquo;Quoted&rsquo; words in a larger quote.&rdquo;<br />

tests/extensions/smarty.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
'.
1+
'.
22
1440--80's
33
1440--'80s
44
1440---'80s

0 commit comments

Comments
 (0)