From 93d79416d155857202c9ef156ae467d4f1fea037 Mon Sep 17 00:00:00 2001 From: Dmitry Shachnev Date: Sat, 20 Jun 2015 15:41:05 +0300 Subject: Override regex for html inline pattern when smart_angled_quotes is true Add a restriction that the closing angled quote should not be duplicate, so that we can use our own pattern for handling duplicate quotes. --- markdown/extensions/smarty.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/markdown/extensions/smarty.py b/markdown/extensions/smarty.py index 46e54c1..600d74c 100644 --- a/markdown/extensions/smarty.py +++ b/markdown/extensions/smarty.py @@ -83,7 +83,7 @@ smartypants.py license: 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 @@ closingSingleQuotesRegex2 = r"(?<=%s)'(\s|s\b)" % closeClass remainingSingleQuotesRegex = "'" remainingDoubleQuotesRegex = '"' +HTML_STRICT_RE = HTML_RE + r'(?!\>)' + class SubstituteTextPattern(HtmlPattern): def __init__(self, pattern, replace, markdown_instance): @@ -251,6 +253,9 @@ class SmartyExtension(Extension): 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) -- cgit v1.2.3