|
83 | 83 |
|
84 | 84 | from __future__ import unicode_literals |
85 | 85 | from . import Extension |
86 | | -from ..inlinepatterns import HtmlPattern |
| 86 | +from ..inlinepatterns import HtmlPattern, HTML_RE |
87 | 87 | from ..odict import OrderedDict |
88 | 88 | from ..treeprocessors import InlineProcessor |
89 | 89 |
|
|
147 | 147 | remainingSingleQuotesRegex = "'" |
148 | 148 | remainingDoubleQuotesRegex = '"' |
149 | 149 |
|
| 150 | +HTML_STRICT_RE = HTML_RE + r'(?!\>)' |
| 151 | + |
150 | 152 |
|
151 | 153 | class SubstituteTextPattern(HtmlPattern): |
152 | 154 | def __init__(self, pattern, replace, markdown_instance): |
@@ -211,10 +213,10 @@ def educateAngledQuotes(self, md): |
211 | 213 | rightAngledQuotePattern = SubstituteTextPattern( |
212 | 214 | r'\>\>', (self.substitutions['right-angle-quote'],), md |
213 | 215 | ) |
214 | | - self.angledQuotesPatterns.add( |
| 216 | + self.inlinePatterns.add( |
215 | 217 | 'smarty-left-angle-quotes', leftAngledQuotePattern, '_begin' |
216 | 218 | ) |
217 | | - self.angledQuotesPatterns.add( |
| 219 | + self.inlinePatterns.add( |
218 | 220 | 'smarty-right-angle-quotes', |
219 | 221 | rightAngledQuotePattern, |
220 | 222 | '>smarty-left-angle-quotes' |
@@ -249,18 +251,17 @@ def extendMarkdown(self, md, md_globals): |
249 | 251 | self.educateEllipses(md) |
250 | 252 | if configs['smart_quotes']: |
251 | 253 | self.educateQuotes(md) |
| 254 | + if configs['smart_angled_quotes']: |
| 255 | + self.educateAngledQuotes(md) |
| 256 | + # Override HTML_RE from inlinepatterns.py so that it does not |
| 257 | + # process tags with duplicate closing quotes. |
| 258 | + md.inlinePatterns["html"] = HtmlPattern(HTML_STRICT_RE, md) |
252 | 259 | if configs['smart_dashes']: |
253 | 260 | self.educateDashes(md) |
254 | 261 | inlineProcessor = InlineProcessor(md) |
255 | 262 | inlineProcessor.inlinePatterns = self.inlinePatterns |
256 | 263 | md.treeprocessors.add('smarty', inlineProcessor, '_end') |
257 | 264 | md.ESCAPED_CHARS.extend(['"', "'"]) |
258 | | - if configs['smart_angled_quotes']: |
259 | | - self.angledQuotesPatterns = OrderedDict() |
260 | | - self.educateAngledQuotes(md) |
261 | | - angledQuotesProcessor = InlineProcessor(md) |
262 | | - angledQuotesProcessor.inlinePatterns = self.angledQuotesPatterns |
263 | | - md.treeprocessors.add('smarty-angledquotes', angledQuotesProcessor, '<inline') |
264 | 265 |
|
265 | 266 |
|
266 | 267 | def makeExtension(*args, **kwargs): |
|
0 commit comments