aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWaylan Limberg <waylan.limberg@icloud.com>2015-01-31 12:14:38 -0500
committerWaylan Limberg <waylan.limberg@icloud.com>2015-01-31 12:14:38 -0500
commit82ad7a9c155a7b9813a48b10479d1b742690deaa (patch)
tree00382b75b4fa95c86ccfd3e64a1d0649e18c36c1
parent17123eaf6eb72a60bf6c5b8a1ad0457187387879 (diff)
downloadmarkdown-82ad7a9c155a7b9813a48b10479d1b742690deaa.tar.gz
markdown-82ad7a9c155a7b9813a48b10479d1b742690deaa.tar.bz2
markdown-82ad7a9c155a7b9813a48b10479d1b742690deaa.zip
Use newer ElementTree API to avoid future breakage.
-rw-r--r--markdown/blockprocessors.py2
-rw-r--r--markdown/extensions/admonition.py2
-rw-r--r--markdown/extensions/codehilite.py7
-rw-r--r--markdown/extensions/def_list.py2
-rw-r--r--markdown/extensions/footnotes.py2
-rw-r--r--markdown/extensions/headerid.py2
-rw-r--r--markdown/extensions/toc.py2
7 files changed, 9 insertions, 10 deletions
diff --git a/markdown/blockprocessors.py b/markdown/blockprocessors.py
index 9c137df..a516fb4 100644
--- a/markdown/blockprocessors.py
+++ b/markdown/blockprocessors.py
@@ -148,7 +148,7 @@ class ListIndentProcessor(BlockProcessor):
return block.startswith(' '*self.tab_length) and \
not self.parser.state.isstate('detabbed') and \
(parent.tag in self.ITEM_TYPES or
- (len(parent) and parent[-1] and
+ (len(parent) and parent[-1] is not None and
(parent[-1].tag in self.LIST_TYPES)))
def run(self, parent, blocks):
diff --git a/markdown/extensions/admonition.py b/markdown/extensions/admonition.py
index 87d8ec8..76e0fb5 100644
--- a/markdown/extensions/admonition.py
+++ b/markdown/extensions/admonition.py
@@ -46,7 +46,7 @@ class AdmonitionProcessor(BlockProcessor):
def test(self, parent, block):
sibling = self.lastChild(parent)
return self.RE.search(block) or \
- (block.startswith(' ' * self.tab_length) and sibling and
+ (block.startswith(' ' * self.tab_length) and sibling is not None and
sibling.get('class', '').find(self.CLASSNAME) != -1)
def run(self, parent, blocks):
diff --git a/markdown/extensions/codehilite.py b/markdown/extensions/codehilite.py
index 211db21..f1e51f9 100644
--- a/markdown/extensions/codehilite.py
+++ b/markdown/extensions/codehilite.py
@@ -201,12 +201,11 @@ class HiliteTreeprocessor(Treeprocessor):
def run(self, root):
""" Find code blocks and store in htmlStash. """
- blocks = root.getiterator('pre')
+ blocks = root.iter('pre')
for block in blocks:
- children = block.getchildren()
- if len(children) == 1 and children[0].tag == 'code':
+ if len(block) == 1 and block[0].tag == 'code':
code = CodeHilite(
- children[0].text,
+ block[0].text,
linenums=self.config['linenums'],
guess_lang=self.config['guess_lang'],
css_class=self.config['css_class'],
diff --git a/markdown/extensions/def_list.py b/markdown/extensions/def_list.py
index 118b739..77cca6e 100644
--- a/markdown/extensions/def_list.py
+++ b/markdown/extensions/def_list.py
@@ -64,7 +64,7 @@ class DefListProcessor(BlockProcessor):
else:
state = 'list'
- if sibling and sibling.tag == 'dl':
+ if sibling is not None and sibling.tag == 'dl':
# This is another item on an existing list
dl = sibling
if not terms and len(dl) and dl[-1].tag == 'dd' and len(dl[-1]):
diff --git a/markdown/extensions/footnotes.py b/markdown/extensions/footnotes.py
index 4779f0c..d8caae2 100644
--- a/markdown/extensions/footnotes.py
+++ b/markdown/extensions/footnotes.py
@@ -287,7 +287,7 @@ class FootnoteTreeprocessor(Treeprocessor):
def run(self, root):
footnotesDiv = self.footnotes.makeFootnotesDiv(root)
- if footnotesDiv:
+ if footnotesDiv is not None:
result = self.footnotes.findFootnotesPlaceholder(root)
if result:
child, parent, isText = result
diff --git a/markdown/extensions/headerid.py b/markdown/extensions/headerid.py
index 67c9b7d..2cb20b9 100644
--- a/markdown/extensions/headerid.py
+++ b/markdown/extensions/headerid.py
@@ -33,7 +33,7 @@ class HeaderIdTreeprocessor(Treeprocessor):
start_level, force_id = self._get_meta()
slugify = self.config['slugify']
sep = self.config['separator']
- for elem in doc.getiterator():
+ for elem in doc:
if elem.tag in ['h1', 'h2', 'h3', 'h4', 'h5', 'h6']:
if force_id:
if "id" in elem.attrib:
diff --git a/markdown/extensions/toc.py b/markdown/extensions/toc.py
index 25d5d97..fdfa687 100644
--- a/markdown/extensions/toc.py
+++ b/markdown/extensions/toc.py
@@ -178,7 +178,7 @@ class TocTreeprocessor(Treeprocessor):
anchor.attrib["href"] = "#" + elem_id
anchor.attrib["class"] = "toclink"
c.text = ""
- for elem in c.getchildren():
+ for elem in c:
anchor.append(elem)
c.remove(elem)
c.append(anchor)