aboutsummaryrefslogtreecommitdiffstats
path: root/markdown/treeprocessors.py
diff options
context:
space:
mode:
authorWaylan Limberg <waylan.limberg@icloud.com>2018-07-27 10:55:41 -0400
committerGitHub <noreply@github.com>2018-07-27 10:55:41 -0400
commit25482261a494ad12c108435580ed13927bdc417c (patch)
tree5b108a5923322d5ceb3fa47d5f05d27a1039de7c /markdown/treeprocessors.py
parent55d69f408cfabed6bd5953a4e7bfc926df2ac25b (diff)
downloadmarkdown-25482261a494ad12c108435580ed13927bdc417c.tar.gz
markdown-25482261a494ad12c108435580ed13927bdc417c.tar.bz2
markdown-25482261a494ad12c108435580ed13927bdc417c.zip
All Markdown instances are now 'md'. (#691)
Previously, instances of the Markdown class were represented as any one of 'md', 'md_instance', or 'markdown'. This inconsistency made it difficult when developing extensions, or just maintaining the existing code. Now, all instances are consistently represented as 'md'. The old attributes on class instances still exist, but raise a DeprecationWarning when accessed. Also on classes where the instance was optional, the attribute always exists now and is simply None if no instance was provided (previously the attribute wouldn't exist).
Diffstat (limited to 'markdown/treeprocessors.py')
-rw-r--r--markdown/treeprocessors.py14
1 files changed, 10 insertions, 4 deletions
diff --git a/markdown/treeprocessors.py b/markdown/treeprocessors.py
index 0177e43..d8d27ff 100644
--- a/markdown/treeprocessors.py
+++ b/markdown/treeprocessors.py
@@ -4,11 +4,11 @@ from . import util
from . import inlinepatterns
-def build_treeprocessors(md_instance, **kwargs):
+def build_treeprocessors(md, **kwargs):
""" Build the default treeprocessors for Markdown. """
treeprocessors = util.Registry()
- treeprocessors.register(InlineProcessor(md_instance), 'inline', 20)
- treeprocessors.register(PrettifyTreeprocessor(md_instance), 'prettify', 10)
+ treeprocessors.register(InlineProcessor(md), 'inline', 20)
+ treeprocessors.register(PrettifyTreeprocessor(md), 'prettify', 10)
return treeprocessors
@@ -51,10 +51,16 @@ class InlineProcessor(Treeprocessor):
self.__placeholder_length = 4 + len(self.__placeholder_prefix) \
+ len(self.__placeholder_suffix)
self.__placeholder_re = util.INLINE_PLACEHOLDER_RE
- self.markdown = md
+ self.md = md
self.inlinePatterns = md.inlinePatterns
self.ancestors = []
+ @property
+ @util.deprecated("Use 'md' instead.")
+ def markdown(self):
+ # TODO: remove this later
+ return self.md
+
def __makePlaceholder(self, type):
""" Generate a placeholder """
id = "%04d" % len(self.stashed_nodes)