PDF Input: Add dummy alt text to images to silence the egregious epubcheck

This commit is contained in:
Kovid Goyal 2021-09-21 09:27:20 +05:30
parent 058353b278
commit 325ced46cb
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C

View File

@ -172,4 +172,13 @@ def flip_images(raw):
continue
flip_image(img, flip)
raw = re.sub(r'<STYLE.+?</STYLE>\s*', '', raw, flags=re.I|re.DOTALL)
counter = 0
def add_alt(m):
nonlocal counter
counter += 1
return m.group(1).rstrip('/') + f' alt="Image {counter}"/>'
raw = re.sub('(<IMG[^>]+)/?>', add_alt, raw, flags=re.I)
return raw