aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--markdown/extensions/smarty.py19
-rw-r--r--tests/basic/inline-html-simple.html3
-rw-r--r--tests/basic/inline-html-simple.txt2
-rw-r--r--tests/extensions/smarty.html2
-rw-r--r--tests/extensions/smarty.txt2
5 files changed, 16 insertions, 12 deletions
diff --git a/markdown/extensions/smarty.py b/markdown/extensions/smarty.py
index 223f2ad..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):
@@ -211,10 +213,10 @@ class SmartyExtension(Extension):
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 @@ class SmartyExtension(Extension):
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, '<inline')
def makeExtension(*args, **kwargs):
diff --git a/tests/basic/inline-html-simple.html b/tests/basic/inline-html-simple.html
index 2159e1d..0f2633c 100644
--- a/tests/basic/inline-html-simple.html
+++ b/tests/basic/inline-html-simple.html
@@ -57,4 +57,5 @@ Blah
<hr class="foo" id="bar" >
-<p><some <a href="http://example.com">weird</a> stuff></p> \ No newline at end of file
+<p><some <a href="http://example.com">weird</a> stuff></p>
+<p><some>&gt; &lt;<unbalanced>&gt; &lt;<brackets></p> \ No newline at end of file
diff --git a/tests/basic/inline-html-simple.txt b/tests/basic/inline-html-simple.txt
index 7210750..359aca4 100644
--- a/tests/basic/inline-html-simple.txt
+++ b/tests/basic/inline-html-simple.txt
@@ -68,3 +68,5 @@ Hr's:
<hr class="foo" id="bar" >
<some [weird](http://example.com) stuff>
+
+<some>> <<unbalanced>> <<brackets> \ No newline at end of file
diff --git a/tests/extensions/smarty.html b/tests/extensions/smarty.html
index a4ec1a0..50cf774 100644
--- a/tests/extensions/smarty.html
+++ b/tests/extensions/smarty.html
@@ -24,7 +24,7 @@ Anführungszeichen-&raquo;Chevrons&laquo;</p>
Escaped ellipsis...</p>
<p>&lsquo;Escaped "quotes" in real ones&rsquo;<br />
'&ldquo;Real&rdquo; quotes in escaped ones'</p>
-<p>Skip <code>"code" -- --- 'spans' ...</code>.</p>
+<p>Skip <code>&lt;&lt;all&gt;&gt; "code" -- --- 'spans' ...</code>.</p>
<pre><code>Also skip "code" 'blocks'
foo -- bar --- baz ...
</code></pre> \ No newline at end of file
diff --git a/tests/extensions/smarty.txt b/tests/extensions/smarty.txt
index d7cba6a..f2f4041 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 `<<all>> "code" -- --- 'spans' ...`.
Also skip "code" 'blocks'
foo -- bar --- baz ...