Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions markdown/extensions/smarty.py
Original file line number Diff line number Diff line change
Expand Up @@ -211,10 +211,10 @@ def educateAngledQuotes(self, md):
rightAngledQuotePattern = SubstituteTextPattern(
r'\>\>', (self.substitutions['right-angle-quote'],), md
)
self.inlinePatterns.add(
self.angledQuotesPatterns.add(
'smarty-left-angle-quotes', leftAngledQuotePattern, '_begin'
)
self.inlinePatterns.add(
self.angledQuotesPatterns.add(
'smarty-right-angle-quotes',
rightAngledQuotePattern,
'>smarty-left-angle-quotes'
Expand Down Expand Up @@ -249,14 +249,18 @@ def extendMarkdown(self, md, md_globals):
self.educateEllipses(md)
if configs['smart_quotes']:
self.educateQuotes(md)
if configs['smart_angled_quotes']:
self.educateAngledQuotes(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):
Expand Down
1 change: 1 addition & 0 deletions tests/extensions/smarty.html
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
&ldquo;<a href="http://example.com">Link</a>&rdquo; &mdash; she said.</p>
<p>&ldquo;Ellipsis within quotes&hellip;&rdquo;</p>
<p>Кавычки-&laquo;ёлочки&raquo;<br />
&laquo;hello&raquo;<br />
Anführungszeichen-&raquo;Chevrons&laquo;</p>
<hr />
<p>Escaped -- ndash<br />
Expand Down
1 change: 1 addition & 0 deletions tests/extensions/smarty.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ em-dashes (---) and ellipes (...)
"Ellipsis within quotes..."

Кавычки-<<ёлочки>>
<<hello>>
Anführungszeichen->>Chevrons<<

--- -- ---
Expand Down