aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDmitry Shachnev <mitya57@gmail.com>2015-06-20 15:41:05 +0300
committerDmitry Shachnev <mitya57@gmail.com>2015-06-20 16:00:15 +0300
commit93d79416d155857202c9ef156ae467d4f1fea037 (patch)
tree80d57767ddd9410b5d4bbd7126e9ef4857e448e8
parentc906d6db38edf68ec45cd412bf3277f1328949f2 (diff)
downloadmarkdown-93d79416d155857202c9ef156ae467d4f1fea037.tar.gz
markdown-93d79416d155857202c9ef156ae467d4f1fea037.tar.bz2
markdown-93d79416d155857202c9ef156ae467d4f1fea037.zip
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.
-rw-r--r--markdown/extensions/smarty.py7
1 files changed, 6 insertions, 1 deletions
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)