aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDmitry Shachnev <mitya57@gmail.com>2014-05-26 10:44:56 +0400
committerDmitry Shachnev <mitya57@gmail.com>2014-05-26 10:47:40 +0400
commit47ec0cb1ea31125da1481fb82319f0a1cdfd20e1 (patch)
tree2550da74c9aef1826a400a8065a7940b1503e797
parent54527a062fd4fe861a59cc994535f01acbf8d643 (diff)
downloadmarkdown-47ec0cb1ea31125da1481fb82319f0a1cdfd20e1.tar.gz
markdown-47ec0cb1ea31125da1481fb82319f0a1cdfd20e1.tar.bz2
markdown-47ec0cb1ea31125da1481fb82319f0a1cdfd20e1.zip
Make smarty extension use its own InlineProcessor
-rw-r--r--markdown/extensions/smarty.py16
1 files changed, 11 insertions, 5 deletions
diff --git a/markdown/extensions/smarty.py b/markdown/extensions/smarty.py
index 2f946f8..6f15d2c 100644
--- a/markdown/extensions/smarty.py
+++ b/markdown/extensions/smarty.py
@@ -68,6 +68,8 @@
from __future__ import unicode_literals
from . import Extension
from ..inlinepatterns import HtmlPattern
+from ..odict import OrderedDict
+from ..treeprocessors import InlineProcessor
from ..util import parseBoolValue
# Constants for quote education.
@@ -145,20 +147,20 @@ class SmartyExtension(Extension):
for ind, pattern in enumerate(patterns):
pattern += (md,)
pattern = SubstituteTextPattern(*pattern)
- after = ('>smarty-%s-%d' % (serie, ind - 1) if ind else '>entity')
+ after = ('>smarty-%s-%d' % (serie, ind - 1) if ind else '_begin')
name = 'smarty-%s-%d' % (serie, ind)
- md.inlinePatterns.add(name, pattern, after)
+ self.inlinePatterns.add(name, pattern, after)
def educateDashes(self, md):
emDashesPattern = SubstituteTextPattern(r'(?<!-)---(?!-)', ('&mdash;',), md)
enDashesPattern = SubstituteTextPattern(r'(?<!-)--(?!-)', ('&ndash;',), md)
- md.inlinePatterns.add('smarty-em-dashes', emDashesPattern, '>entity')
- md.inlinePatterns.add('smarty-en-dashes', enDashesPattern,
+ self.inlinePatterns.add('smarty-em-dashes', emDashesPattern, '_begin')
+ self.inlinePatterns.add('smarty-en-dashes', enDashesPattern,
'>smarty-em-dashes')
def educateEllipses(self, md):
ellipsesPattern = SubstituteTextPattern(r'(?<!\.)\.{3}(?!\.)', ('&hellip;',), md)
- md.inlinePatterns.add('smarty-ellipses', ellipsesPattern, '>entity')
+ self.inlinePatterns.add('smarty-ellipses', ellipsesPattern, '_begin')
def educateQuotes(self, md):
patterns = (
@@ -179,12 +181,16 @@ class SmartyExtension(Extension):
def extendMarkdown(self, md, md_globals):
configs = self.getConfigs()
+ self.inlinePatterns = OrderedDict()
if configs['smart_quotes']:
self.educateQuotes(md)
if configs['smart_dashes']:
self.educateDashes(md)
if configs['smart_ellipses']:
self.educateEllipses(md)
+ inlineProcessor = InlineProcessor(md)
+ inlineProcessor.inlinePatterns = self.inlinePatterns
+ md.treeprocessors.add('smarty', inlineProcessor, '_end')
md.ESCAPED_CHARS.extend(['"', "'"])
def makeExtension(configs=None):