From 12abecc933f30aea980d9bea1a709b3c682bb45b Mon Sep 17 00:00:00 2001 From: Michel Roux Date: Thu, 13 Feb 2025 19:47:08 +0000 Subject: [PATCH] fix: :bug: fix links --- auberge_vagabonde/__main__.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/auberge_vagabonde/__main__.py b/auberge_vagabonde/__main__.py index 799ef40..e62fc4c 100644 --- a/auberge_vagabonde/__main__.py +++ b/auberge_vagabonde/__main__.py @@ -44,9 +44,9 @@ class MyChapterFactory(SimpleChapterFactory): # type: ignore # return new element-tree 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] = {} for image in ctx.etree.xpath(".//img[@src]"): @@ -101,8 +101,14 @@ class MyChapterFactory(SimpleChapterFactory): # type: ignore image.attrib["src"] = epub_path except error.URLError: 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: - 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: