mirror of
https://github.com/kemayo/leech
synced 2025-12-06 16:33:16 +01:00
In no-images case, replace with alt if present rather than decomposing
Putting a placeholder there for the altless, to avoid confusion.
This commit is contained in:
parent
740a41f4ef
commit
3fbe181b12
1 changed files with 3 additions and 2 deletions
|
|
@ -132,9 +132,10 @@ def chapter_html(
|
||||||
# Remove all images from the chapter so you don't get that annoying grey background.
|
# Remove all images from the chapter so you don't get that annoying grey background.
|
||||||
for img in soup.find_all('img'):
|
for img in soup.find_all('img'):
|
||||||
if img.parent.name.lower() == "figure":
|
if img.parent.name.lower() == "figure":
|
||||||
img.parent.decompose()
|
# TODO: figcaption?
|
||||||
|
img.parent.replace_with(img.get('alt', '🖼'))
|
||||||
else:
|
else:
|
||||||
img.decompose()
|
img.replace_with(img.get('alt', '🖼'))
|
||||||
|
|
||||||
title = titleprefix and f'{titleprefix}: {title}' or title
|
title = titleprefix and f'{titleprefix}: {title}' or title
|
||||||
contents = str(soup)
|
contents = str(soup)
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue