diff --git a/markdown/extensions/smarty.py b/markdown/extensions/smarty.py index 223f2adc4..600d74cd6 100644 --- a/markdown/extensions/smarty.py +++ b/markdown/extensions/smarty.py @@ -83,7 +83,7 @@ from __future__ import unicode_literals from . import Extension -from ..inlinepatterns import HtmlPattern +from ..inlinepatterns import HtmlPattern, HTML_RE from ..odict import OrderedDict from ..treeprocessors import InlineProcessor @@ -147,6 +147,8 @@ remainingSingleQuotesRegex = "'" remainingDoubleQuotesRegex = '"' +HTML_STRICT_RE = HTML_RE + r'(?!\>)' + class SubstituteTextPattern(HtmlPattern): def __init__(self, pattern, replace, markdown_instance): @@ -211,10 +213,10 @@ def educateAngledQuotes(self, md): rightAngledQuotePattern = SubstituteTextPattern( r'\>\>', (self.substitutions['right-angle-quote'],), md ) - self.angledQuotesPatterns.add( + self.inlinePatterns.add( 'smarty-left-angle-quotes', leftAngledQuotePattern, '_begin' ) - self.angledQuotesPatterns.add( + self.inlinePatterns.add( 'smarty-right-angle-quotes', rightAngledQuotePattern, '>smarty-left-angle-quotes' @@ -249,18 +251,17 @@ def extendMarkdown(self, md, md_globals): self.educateEllipses(md) if configs['smart_quotes']: self.educateQuotes(md) + if configs['smart_angled_quotes']: + self.educateAngledQuotes(md) + # Override HTML_RE from inlinepatterns.py so that it does not + # process tags with duplicate closing quotes. + md.inlinePatterns["html"] = HtmlPattern(HTML_STRICT_RE, 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, ' -

weird stuff>

\ No newline at end of file +

weird stuff>

+

> <> <

\ No newline at end of file diff --git a/tests/basic/inline-html-simple.txt b/tests/basic/inline-html-simple.txt index 7210750d8..359aca4e5 100644 --- a/tests/basic/inline-html-simple.txt +++ b/tests/basic/inline-html-simple.txt @@ -68,3 +68,5 @@ Hr's:
+ +> <> < \ No newline at end of file diff --git a/tests/extensions/smarty.html b/tests/extensions/smarty.html index a4ec1a05f..50cf77440 100644 --- a/tests/extensions/smarty.html +++ b/tests/extensions/smarty.html @@ -24,7 +24,7 @@ Escaped ellipsis...

‘Escaped "quotes" in real ones’
'“Real” quotes in escaped ones'

-

Skip "code" -- --- 'spans' ....

+

Skip <<all>> "code" -- --- 'spans' ....

Also skip "code" 'blocks'
 foo -- bar --- baz ...
 
\ No newline at end of file diff --git a/tests/extensions/smarty.txt b/tests/extensions/smarty.txt index d7cba6a61..f2f4041b5 100644 --- a/tests/extensions/smarty.txt +++ b/tests/extensions/smarty.txt @@ -31,7 +31,7 @@ Escaped ellipsis\... 'Escaped \"quotes\" in real ones' \'"Real" quotes in escaped ones\' -Skip `"code" -- --- 'spans' ...`. +Skip `<> "code" -- --- 'spans' ...`. Also skip "code" 'blocks' foo -- bar --- baz ...