Closed rshiva closed 5 months ago
I'm not sure Mobi supports remote images at all. In #333, asciidoctor-epub3 was fixed to pass URLs to EPUB. Mobi is created from EPUB using KindleGen and looks like the latter doesn't support remote URLs. We could add some hacks like "if we are producing Mobi, download remote resource and use that". The problem is that is isn't very clear when to download. Should we do it on each and every conversion? Or we should cache file? But when to re-download it?
Thanks for the quick reply. Is it possible, whenever a URL is provided we download the images from the URL and put in a temporary folder or cache then read the images from there to create the Mobi and delete the cache after converting. I think it would make sense to download the images on every conversion. @slonopotamus Thanks for your contribution 😄
We should not reinvent the wheel and just implement this logic: https://docs.asciidoctor.org/asciidoc/latest/directives/include-uri/
Hmm... Looks like we already can do that:
asciidoctor-epub3 -D output -a ebook-format=kf8 -a data-uri -a allow-uri-read chapter1.adoc
@rshiva does this work for you?
Note that you cannot use SVG images because Mobi doesn't support that.
The logic to fetch a remote image, and to even cache it, is already provided by Asciidoctor core. See this method: https://github.com/asciidoctor/asciidoctor/blob/main/lib/asciidoctor/abstract_node.rb#L322-L334
The downside of that method is that it returns the image as a data URI instead of as a File reference. However, you can find a different implementation in Asciidoctor PDF that returns a temporary file path: https://github.com/asciidoctor/asciidoctor-pdf/blob/main/lib/asciidoctor/pdf/converter.rb#L4240-L4259
Suffice to say, this is a solved problem in Asciidoctor. It's just a matter of reusing the code which is already available.
-a data-uri
Indeed, this is one approach that leverages the logic I linked to in Asciidoctor core. If you prefer to have it add the image files to the manifest, then you would need the code from Asciidoctor PDF.
Yep, there are some downsides using -a data-uri
, but it might be Good Enough as a quick-and-dirty workaround.
Hmm... Looks like we already can do that:
asciidoctor-epub3 -D output -a ebook-format=kf8 -a data-uri -a allow-uri-read chapter1.adoc
@rshiva does this work for you?
Note that you cannot use SVG images because Mobi doesn't support that.
Thanks @mojavelinux and @slonopotamus this worked
asciidoctor-epub3 no longer support producing MOBI/KF8, see https://github.com/asciidoctor/asciidoctor-epub3/pull/458.
Asciidoctors, I'm unable to generate/view the image from a remote URL while generating the Mobi. Whereas it works for asciidoctor when converting adoc to HTML
Code look something like this
Am I missing something? Please guide I'm totally new to Asciidoctor. This https://github.com/asciidoctor/asciidoctor-epub3/issues/333 issue says remote URL issue is resolved