Skip to content

Commit 43163a2

Browse files
authored
'src' attribute XML bug
1 parent af1b6d8 commit 43163a2

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

astropylibrarian/reducers/tutorial.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -349,11 +349,14 @@ def process_html(self, html_page: HtmlPage) -> None:
349349
image_elements = doc.cssselect("img")
350350
logger.debug(f"Found {len(image_elements)} image elements")
351351
for image_element in image_elements:
352-
img_src = image_element.attrib["src"]
353-
if img_src.startswith("data:"):
354-
# skip embedded images
355-
continue
356-
self._images.append(urljoin(self.url, img_src))
352+
img_src = image_element.attrib.get("src")
353+
if img_src is not None:
354+
if img_src.startswith("data:"):
355+
# skip embedded images
356+
continue
357+
self._images.append(urljoin(self.url, img_src))
358+
else:
359+
logger.debug(f"Image element {image_element} missing attribute 'src'")
357360

358361
root_section = doc.cssselect("section")[0]
359362
for s in iter_sphinx_sections(

0 commit comments

Comments
 (0)