Skip to content

Commit 633260e

Browse files
victor-ruronreiter
authored andcommittedFeb 4, 2021
added python 3.9 support - removed deprecated ElementTree features
1 parent 435530e commit 633260e

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed
 

‎markdown/treeprocessors.py

+6-6
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ def __processElementText(self, node, subnode, isText=True):
121121
childResult = self.__processPlaceholders(text, subnode)
122122

123123
if not isText and node is not subnode:
124-
pos = node.getchildren().index(subnode)
124+
pos = list(node).index(subnode)
125125
node.remove(subnode)
126126
else:
127127
pos = 0
@@ -169,7 +169,7 @@ def linkText(text):
169169
linkText(text)
170170

171171
if not isString(node): # it's Element
172-
for child in [node] + node.getchildren():
172+
for child in [node] + list(node):
173173
if child.tail:
174174
if child.tail.strip():
175175
self.__processElementText(node, child, False)
@@ -224,7 +224,7 @@ def __applyPattern(self, pattern, data, patternIndex, startIndex=0):
224224
if not isString(node):
225225
if not isinstance(node.text, markdown.AtomicString):
226226
# We need to process current node too
227-
for child in [node] + node.getchildren():
227+
for child in [node] + list(node):
228228
if not isString(node):
229229
if child.text:
230230
child.text = self.__handleInline(child.text,
@@ -263,7 +263,7 @@ def run(self, tree):
263263
while stack:
264264
currElement = stack.pop()
265265
insertQueue = []
266-
for child in currElement.getchildren():
266+
for child in list(currElement):
267267
if child.text and not isinstance(child.text, markdown.AtomicString):
268268
text = child.text
269269
child.text = None
@@ -272,7 +272,7 @@ def run(self, tree):
272272
stack += lst
273273
insertQueue.append((child, lst))
274274

275-
if child.getchildren():
275+
if len(list(child)) > 0:
276276
stack.append(child)
277277

278278
for element, lst in insertQueue:
@@ -321,7 +321,7 @@ def run(self, root):
321321
self._prettifyETree(root)
322322
# Do <br />'s seperately as they are often in the middle of
323323
# inline content and missed by _prettifyETree.
324-
brs = root.getiterator('br')
324+
brs = root.iter('br')
325325
for br in brs:
326326
if not br.tail or not br.tail.strip():
327327
br.tail = '\n'

0 commit comments

Comments
 (0)
Please sign in to comment.