Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Inline images are not included #30

Open
orloffm opened this issue Sep 18, 2015 · 9 comments

Comments

Projects
None yet
5 participants
@orloffm
Copy link

commented Sep 18, 2015

Source:

image::red.png[]

A

image:blue.png[] B

Z

Resulting .epub does not have blue.png file, but it is referenced in the document.

@mojavelinux mojavelinux added the bug label Sep 18, 2015

@mojavelinux mojavelinux added this to the v1.5.0 milestone Sep 18, 2015

@mojavelinux

This comment has been minimized.

Copy link
Member

commented Sep 18, 2015

If I remember correctly, this is a known limitation because the AST does not return inline images.

See https://github.com/asciidoctor/asciidoctor-epub3/blob/master/lib/asciidoctor-epub3/packager.rb#L331

As long as that line gathers all the images, they will get packaged. However, we may need a change to core to expose this metadata.

@orloffm

This comment has been minimized.

Copy link
Author

commented Apr 22, 2016

So the issue is that inline images are Inline, which are not Block, but AbstractNode instead? And one should implement find_by on Inline, right? Can you, please, find time for that?

The world of Ruby is alien to me, even if I manage to do that, I'll never handle doing tests properly.

@mojavelinux

This comment has been minimized.

Copy link
Member

commented Apr 23, 2016

And one should implement find_by on Inline, right?

Unfortunately not. That gets to the heart of the problem. Inline syntax is not parsed during the parse phase. Inline syntax is discovered and converted in a streaming method. The only way to know about the inline images is to enable the catalog_assets option, then look for them in document.references after the conversion happens. Technically, this is possible, but it changes the strategy for how the images are added to the archive.

What I probably need to do is add the images to the archive after adding the content. That way, the documents will already be converted and therefore should have a reference to the images. I would switch from looking for images using find_by to getting the list of images from document.references.

@mojavelinux

This comment has been minimized.

Copy link
Member

commented Apr 23, 2016

There is one workaround you can use. You can create a front-matter.html file and add all the inline images inside a comment block (or hidden element). The converter will add these images to the archive. (See https://github.com/asciidoctor/asciidoctor-epub3/blob/v1.5.0.alpha.6/lib/asciidoctor-epub3/packager.rb#L159-L167). The downside is that you will get a blank page in the EPUB3 file, though you could put something on this page just so it isn't blank.

@mojavelinux

This comment has been minimized.

Copy link
Member

commented Apr 23, 2016

Solving this issue requires a rather deep understanding of how a) the EPUB3 packager works and b) how Asciidoctor manages images using catalog_assets. It's a tough one.

@mojavelinux mojavelinux self-assigned this Apr 23, 2016

@mojavelinux mojavelinux added the next label Apr 23, 2016

@ProgramFan

This comment has been minimized.

Copy link

commented Aug 20, 2016

This is really tough.

@mojavelinux

This comment has been minimized.

Copy link
Member

commented Aug 20, 2016

Actually, it's not that tough now that we have performed processing of an inline macro in the mathematical extension. We either need to use a Treeprocessor or we can look at the image catalog after conversion. We may need to monkeypatch core in order to close some gaps, but it's definitely doable.

@mojavelinux mojavelinux modified the milestones: v1.5.0.alpha.8, v1.5.0 Apr 9, 2017

@Patola

This comment has been minimized.

Copy link

commented Sep 30, 2017

Agh. This bug is biting me HARD. Sorry because I know it is a difficult task, but any progress on that? I am using asciidoctor-mathematical for some formulas, and that's the last thing I need to render a proper epub.

@madeindjs

This comment has been minimized.

Copy link

commented Jan 9, 2019

Any progress on that? I can't export my project to EPUB. Also the :front-cover-image: does not work too. This my example:

= API on Rails 5
// ...
:imagesdir: ../img
:front-cover-image: image:cover.svg[]

You can see the complete example here

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.