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

Support images with absolute paths #465

Open
someth2say opened this issue Feb 22, 2024 · 1 comment
Open

Support images with absolute paths #465

someth2say opened this issue Feb 22, 2024 · 1 comment

Comments

@someth2say
Copy link
Contributor

someth2say commented Feb 22, 2024

AsciiDoctor documentation states that The value of imagesdir can be an absolute path, relative path or URL.

Nonetheles, using an absolute path causes the image to not be included in the ePub file.

Reproducer: If the following imagesdir.adoc file and the image.svg are in /tmp

= Book
:imagesdir: {docdir}

image::./image.svg[]

Causes raises the following error:

asciidoctor: ERROR: imagesdir.adoc: media file not found or not readable: /tmp/tmp/image.svg
@slonopotamus
Copy link
Contributor

slonopotamus commented Jan 12, 2025

There are multiple issues here.

First, our logic in register_media_file is broken:

        if Asciidoctor::Helpers.uriish? target
          # We need to add both local and remote media files to manifest
          fs_path = nil
        else
          out_dir = node.attr('outdir', nil, true) || doc_option(node.document, :to_dir)
          fs_path = (::File.join out_dir, target) <-------------------------
          unless ::File.exist? fs_path
            base_dir = root_document(node.document).base_dir
            fs_path = ::File.join base_dir, target
          end
        end

Second, asciidoctor-epub3 assumes that "virtual" path (that is specified in AsciiDoc source) can be used as-is inside epub file. But this is not true in your case. Looks like we need to generate some path that would be used inside epub file.

slonopotamus added a commit to slonopotamus/asciidoctor-epub3 that referenced this issue Jan 12, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants