From 579288c5eb684dd09d1ef298929a566f40151205 Mon Sep 17 00:00:00 2001 From: Waylan Limberg Date: Wed, 27 Feb 2013 09:10:47 -0500 Subject: 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. --- markdown/extensions/toc.py | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) (limited to 'markdown/extensions/toc.py') diff --git a/markdown/extensions/toc.py b/markdown/extensions/toc.py index 1d6639e..f50f11b 100644 --- a/markdown/extensions/toc.py +++ b/markdown/extensions/toc.py @@ -1,3 +1,4 @@ +from __future__ import unicode_literals """ Table of Contents Extension for Python-Markdown * * * @@ -8,10 +9,12 @@ Dependencies: * [Markdown 2.1+](http://packages.python.org/Markdown/) """ -import markdown -from markdown.util import etree -from markdown.extensions.headerid import slugify, unique, itertext +from __future__ import absolute_import +from . import Extension +from ..treeprocessors import Treeprocessor +from ..util import etree +from .headerid import slugify, unique, itertext import re @@ -77,7 +80,7 @@ def order_toc_list(toc_list): return ordered_list -class TocTreeprocessor(markdown.treeprocessors.Treeprocessor): +class TocTreeprocessor(Treeprocessor): # Iterator wrapper to get parent and child all at once def iterparent(self, root): @@ -182,7 +185,7 @@ class TocTreeprocessor(markdown.treeprocessors.Treeprocessor): self.markdown.toc = toc -class TocExtension(markdown.Extension): +class TocExtension(Extension): TreeProcessorClass = TocTreeprocessor -- cgit v1.2.3