aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGertjan van den Burg <gertjanvandenburg@gmail.com>2020-04-27 17:26:42 +0100
committerGertjan van den Burg <gertjanvandenburg@gmail.com>2020-04-27 17:26:42 +0100
commit3224b3857cc2f11226043ced1da586756403cbb1 (patch)
treee24ed22120bf0a108fb586de3ddd76dda8e0c71b
parentMerge branch 'master' into bugfix/html-images (diff)
downloadpaper2remarkable-3224b3857cc2f11226043ced1da586756403cbb1.tar.gz
paper2remarkable-3224b3857cc2f11226043ced1da586756403cbb1.zip
Use builtin iter() function to find img elements
-rw-r--r--paper2remarkable/providers/html.py9
1 files changed, 1 insertions, 8 deletions
diff --git a/paper2remarkable/providers/html.py b/paper2remarkable/providers/html.py
index bbafe10..ba250e7 100644
--- a/paper2remarkable/providers/html.py
+++ b/paper2remarkable/providers/html.py
@@ -61,16 +61,9 @@ class ImgProcessor(markdown.treeprocessors.Treeprocessor):
self._base_url = base_url
super().__init__(*args, **kwargs)
- def _find_img(self, node):
- """ Find img nodes recursively """
- for img in node.findall("img"):
- yield img
- for child in node:
- yield from self._find_img(child)
-
def run(self, root):
""" Ensure all img src urls are absolute """
- for img in self._find_img(root):
+ for img in root.iter("img"):
img.attrib["src"] = urllib.parse.urljoin(
self._base_url, img.attrib["src"]
)