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

Closed
orloffm opened this issue Sep 18, 2015 · 9 comments · Fixed by #283
Closed

Inline images are not included #30

orloffm opened this issue Sep 18, 2015 · 9 comments · Fixed by #283
Assignees

Comments

@orloffm
Copy link

orloffm 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 this to the v1.5.0 milestone Sep 18, 2015
@mojavelinux
Copy link
Member

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
Copy link
Author

orloffm 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
Copy link
Member

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
Copy link
Member

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
Copy link
Member

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.

@ProgramFan
Copy link

This is really tough.

@mojavelinux
Copy link
Member

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
Copy link

Patola 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
Copy link

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

@slonopotamus slonopotamus self-assigned this Jan 25, 2020
slonopotamus added a commit to slonopotamus/asciidoctor-epub3 that referenced this issue Jan 30, 2020
…packaging

resolves asciidoctor#30 inline images are not included
resolves asciidoctor#169 images in tables don't show up
resolves asciidoctor#190 plantumlconfig is looking in the wrong dir
slonopotamus added a commit to slonopotamus/asciidoctor-epub3 that referenced this issue Jan 30, 2020
…packaging

resolves asciidoctor#22 `Image not found or not readable` if `imagesdir` is not in the current directory
resolves asciidoctor#169 images in tables don't show up
resolves asciidoctor#190 plantumlconfig is looking in the wrong dir
resolves asciidoctor#30 Inline images are not included
slonopotamus added a commit to slonopotamus/asciidoctor-epub3 that referenced this issue Jan 30, 2020
…packaging

resolves asciidoctor#22 `Image not found or not readable` if `imagesdir` is not in the current directory
resolves asciidoctor#169 images in tables don't show up
resolves asciidoctor#190 plantumlconfig is looking in the wrong dir
resolves asciidoctor#30 Inline images are not included
slonopotamus added a commit to slonopotamus/asciidoctor-epub3 that referenced this issue Jan 30, 2020
…packaging

resolves asciidoctor#22 `Image not found or not readable` if `imagesdir` is not in the current directory
resolves asciidoctor#169 images in tables don't show up
resolves asciidoctor#190 plantumlconfig is looking in the wrong dir
resolves asciidoctor#30 Inline images are not included
slonopotamus added a commit to slonopotamus/asciidoctor-epub3 that referenced this issue Jan 30, 2020
…packaging

resolves asciidoctor#22 `Image not found or not readable` if `imagesdir` is not in the current directory
resolves asciidoctor#169 images in tables don't show up
resolves asciidoctor#190 plantumlconfig is looking in the wrong dir
resolves asciidoctor#30 Inline images are not included
slonopotamus added a commit to slonopotamus/asciidoctor-epub3 that referenced this issue Jan 31, 2020
…packaging

resolves asciidoctor#22 `Image not found or not readable` if `imagesdir` is not in the current directory
resolves asciidoctor#169 images in tables don't show up
resolves asciidoctor#190 plantumlconfig is looking in the wrong dir
resolves asciidoctor#30 Inline images are not included
slonopotamus added a commit to slonopotamus/asciidoctor-epub3 that referenced this issue Jan 31, 2020
…packaging

resolves asciidoctor#22 `Image not found or not readable` if `imagesdir` is not in the current directory
resolves asciidoctor#169 images in tables don't show up
resolves asciidoctor#190 plantumlconfig is looking in the wrong dir
resolves asciidoctor#30 Inline images are not included
slonopotamus added a commit to slonopotamus/asciidoctor-epub3 that referenced this issue Jan 31, 2020
…packaging

resolves asciidoctor#22 `Image not found or not readable` if `imagesdir` is not in the current directory
resolves asciidoctor#169 images in tables don't show up
resolves asciidoctor#190 plantumlconfig is looking in the wrong dir
resolves asciidoctor#30 Inline images are not included
slonopotamus added a commit to slonopotamus/asciidoctor-epub3 that referenced this issue Jan 31, 2020
…packaging

resolves asciidoctor#169 images in tables don't show up
resolves asciidoctor#190 plantumlconfig is looking in the wrong dir
resolves asciidoctor#30 Inline images are not included
slonopotamus added a commit to slonopotamus/asciidoctor-epub3 that referenced this issue Feb 1, 2020
…packaging

resolves asciidoctor#169 images in tables don't show up
resolves asciidoctor#190 plantumlconfig is looking in the wrong dir
resolves asciidoctor#30 Inline images are not included
slonopotamus added a commit to slonopotamus/asciidoctor-epub3 that referenced this issue Feb 1, 2020
…packaging

resolves asciidoctor#169 images in tables don't show up
resolves asciidoctor#190 plantumlconfig is looking in the wrong dir
resolves asciidoctor#30 Inline images are not included
slonopotamus added a commit to slonopotamus/asciidoctor-epub3 that referenced this issue Feb 3, 2020
…packaging

resolves asciidoctor#169 images in tables don't show up
resolves asciidoctor#190 plantumlconfig is looking in the wrong dir
resolves asciidoctor#30 Inline images are not included
slonopotamus added a commit that referenced this issue Feb 3, 2020
#283)

resolves #169 images in tables don't show up
resolves #190 plantumlconfig is looking in the wrong dir
resolves #30 Inline images are not included
slonopotamus added a commit that referenced this issue Feb 4, 2020
We now *do* package inline images, thanks to #283
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants