aboutsummaryrefslogtreecommitdiffstats
path: root/markdown/treeprocessors.py
diff options
context:
space:
mode:
authorWaylan Limberg <waylan@gmail.com>2013-02-27 09:10:47 -0500
committerWaylan Limberg <waylan@gmail.com>2013-02-27 09:10:47 -0500
commit579288c5eb684dd09d1ef298929a566f40151205 (patch)
treed10a50f91b8606cd1dea38764168abab92958b0f /markdown/treeprocessors.py
parentb37ab16ba56ac6fe4e64f87521996bad323058f2 (diff)
downloadmarkdown-579288c5eb684dd09d1ef298929a566f40151205.tar.gz
markdown-579288c5eb684dd09d1ef298929a566f40151205.tar.bz2
markdown-579288c5eb684dd09d1ef298929a566f40151205.zip
Now using universal code for Python 2 & 3.
The most notable changes are the use of unicode_literals and absolute_imports. Actually, absolute_imports was the biggest deal as it gives us relative imports. For the first time extensions import markdown relative to themselves. This allows other packages to embed the markdown lib in a subdir of their project and still be able to use our extensions.
Diffstat (limited to 'markdown/treeprocessors.py')
-rw-r--r--markdown/treeprocessors.py18
1 files changed, 7 insertions, 11 deletions
diff --git a/markdown/treeprocessors.py b/markdown/treeprocessors.py
index b5eedbd..2df80f8 100644
--- a/markdown/treeprocessors.py
+++ b/markdown/treeprocessors.py
@@ -1,6 +1,8 @@
-import inlinepatterns
-import util
-import odict
+from __future__ import unicode_literals
+from __future__ import absolute_import
+from . import util
+from . import odict
+from . import inlinepatterns
def build_treeprocessors(md_instance, **kwargs):
@@ -14,17 +16,11 @@ def build_treeprocessors(md_instance, **kwargs):
def isString(s):
""" Check if it's string """
if not isinstance(s, util.AtomicString):
- return isinstance(s, basestring)
+ return isinstance(s, util.string_type)
return False
-class Processor:
- def __init__(self, markdown_instance=None):
- if markdown_instance:
- self.markdown = markdown_instance
-
-
-class Treeprocessor(Processor):
+class Treeprocessor(util.Processor):
"""
Treeprocessors are run on the ElementTree object before serialization.