aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWaylan Limberg <waylan.limberg@icloud.com>2015-06-15 14:03:17 -0400
committerWaylan Limberg <waylan.limberg@icloud.com>2015-06-15 14:03:17 -0400
commit789f5165ad7de0f0dd7cc9988e0126c0d732257c (patch)
treeb46824c81e28d9636d38c098099a560fddebb68c
parentc7410d1c6901d04cd41f33d33d4539cc71765f41 (diff)
parent5029d829c1532f31adc9acbf54d88bb469a69a4f (diff)
downloadmarkdown-789f5165ad7de0f0dd7cc9988e0126c0d732257c.tar.gz
markdown-789f5165ad7de0f0dd7cc9988e0126c0d732257c.tar.bz2
markdown-789f5165ad7de0f0dd7cc9988e0126c0d732257c.zip
Merge pull request #417 from mitya57/master
Fix processing angle quotes in smarty extension
-rw-r--r--markdown/extensions/smarty.py12
-rw-r--r--tests/extensions/smarty.html1
-rw-r--r--tests/extensions/smarty.txt1
3 files changed, 10 insertions, 4 deletions
diff --git a/markdown/extensions/smarty.py b/markdown/extensions/smarty.py
index 46e54c1..223f2ad 100644
--- a/markdown/extensions/smarty.py
+++ b/markdown/extensions/smarty.py
@@ -211,10 +211,10 @@ class SmartyExtension(Extension):
rightAngledQuotePattern = SubstituteTextPattern(
r'\>\>', (self.substitutions['right-angle-quote'],), md
)
- self.inlinePatterns.add(
+ self.angledQuotesPatterns.add(
'smarty-left-angle-quotes', leftAngledQuotePattern, '_begin'
)
- self.inlinePatterns.add(
+ self.angledQuotesPatterns.add(
'smarty-right-angle-quotes',
rightAngledQuotePattern,
'>smarty-left-angle-quotes'
@@ -249,14 +249,18 @@ class SmartyExtension(Extension):
self.educateEllipses(md)
if configs['smart_quotes']:
self.educateQuotes(md)
- if configs['smart_angled_quotes']:
- self.educateAngledQuotes(md)
if configs['smart_dashes']:
self.educateDashes(md)
inlineProcessor = InlineProcessor(md)
inlineProcessor.inlinePatterns = self.inlinePatterns
md.treeprocessors.add('smarty', inlineProcessor, '_end')
md.ESCAPED_CHARS.extend(['"', "'"])
+ if configs['smart_angled_quotes']:
+ self.angledQuotesPatterns = OrderedDict()
+ self.educateAngledQuotes(md)
+ angledQuotesProcessor = InlineProcessor(md)
+ angledQuotesProcessor.inlinePatterns = self.angledQuotesPatterns
+ md.treeprocessors.add('smarty-angledquotes', angledQuotesProcessor, '<inline')
def makeExtension(*args, **kwargs):
diff --git a/tests/extensions/smarty.html b/tests/extensions/smarty.html
index d41e467..a4ec1a0 100644
--- a/tests/extensions/smarty.html
+++ b/tests/extensions/smarty.html
@@ -16,6 +16,7 @@ em-dashes (&mdash;) and ellipes (&hellip;)<br />
&ldquo;<a href="http://example.com">Link</a>&rdquo; &mdash; she said.</p>
<p>&ldquo;Ellipsis within quotes&hellip;&rdquo;</p>
<p>Кавычки-&laquo;ёлочки&raquo;<br />
+&laquo;hello&raquo;<br />
Anführungszeichen-&raquo;Chevrons&laquo;</p>
<hr />
<p>Escaped -- ndash<br />
diff --git a/tests/extensions/smarty.txt b/tests/extensions/smarty.txt
index 48430bb..d7cba6a 100644
--- a/tests/extensions/smarty.txt
+++ b/tests/extensions/smarty.txt
@@ -19,6 +19,7 @@ em-dashes (---) and ellipes (...)
"Ellipsis within quotes..."
Кавычки-<<ёлочки>>
+<<hello>>
Anführungszeichen->>Chevrons<<
--- -- ---