This commit is contained in:
parent
9127bdd8ae
commit
12abecc933
@ -44,9 +44,9 @@ class MyChapterFactory(SimpleChapterFactory): # type: ignore
|
|||||||
# return new element-tree
|
# return new element-tree
|
||||||
return etree
|
return etree
|
||||||
|
|
||||||
def hydrate(self, ctx: factory.RenderCtx) -> None:
|
def render_images(self, ctx: factory.RenderCtx) -> None:
|
||||||
"""
|
"""
|
||||||
modify chapter element-tree to render images
|
replace global image references w/ local downloaded ones
|
||||||
"""
|
"""
|
||||||
downloads: dict[str, str] = {}
|
downloads: dict[str, str] = {}
|
||||||
for image in ctx.etree.xpath(".//img[@src]"):
|
for image in ctx.etree.xpath(".//img[@src]"):
|
||||||
@ -101,8 +101,14 @@ class MyChapterFactory(SimpleChapterFactory): # type: ignore
|
|||||||
image.attrib["src"] = epub_path
|
image.attrib["src"] = epub_path
|
||||||
except error.URLError:
|
except error.URLError:
|
||||||
ctx.logger.error("chapter[{}] failed to download {!r}".format(*fmt))
|
ctx.logger.error("chapter[{}] failed to download {!r}".format(*fmt))
|
||||||
|
|
||||||
|
def hydrate(self, ctx: factory.RenderCtx) -> None:
|
||||||
|
"""
|
||||||
|
modify chapter element-tree to render images
|
||||||
|
"""
|
||||||
|
self.render_images(ctx)
|
||||||
if ctx.extern_links and ctx.chapter.url:
|
if ctx.extern_links and ctx.chapter.url:
|
||||||
self.externalize_links(ctx.chapter.url, ctx.etree)
|
factory.externalize_links(ctx.chapter.url, ctx.etree)
|
||||||
|
|
||||||
|
|
||||||
with open(f"{path.dirname(__file__)}/{args.lang}.json") as f:
|
with open(f"{path.dirname(__file__)}/{args.lang}.json") as f:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user