From bb9bb318c28fced49de7ef43cd9cd8c364a8b090 Mon Sep 17 00:00:00 2001 From: Dmitry Shachnev Date: Mon, 15 Jun 2015 17:49:11 +0300 Subject: tests: Add a failing case for `<>` to smarty test --- tests/extensions/smarty.html | 1 + tests/extensions/smarty.txt | 1 + 2 files changed, 2 insertions(+) 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 (—) and ellipes (…)
Link” — she said.

“Ellipsis within quotes…”

Кавычки-«ёлочки»
+«hello»
Anführungszeichen-»Chevrons«


Escaped -- ndash
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..." Кавычки-<<ёлочки>> +<> Anführungszeichen->>Chevrons<< --- -- --- -- cgit v1.2.3 From 5029d829c1532f31adc9acbf54d88bb469a69a4f Mon Sep 17 00:00:00 2001 From: Dmitry Shachnev Date: Mon, 15 Jun 2015 17:50:27 +0300 Subject: smarty: Use a separate processor for angled quotes Run that processor before inline processor to fix the test failure. --- markdown/extensions/smarty.py | 12 ++++++++---- 1 file changed, 8 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, '