-
Notifications
You must be signed in to change notification settings - Fork 172
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
Asset catalog does not include inlined images #1166
Comments
2 things:
@mojavelinux sorry to tag you. Is the assumption correct or am I doing something wrong? Here's my test with asciidoctor gem v2.0.18. require 'asciidoctor'
input_file = 'sample.adoc'
doc = Asciidoctor.load_file(input_file, catalog_assets: true)
images = doc.catalog[:images]
puts "Found #{images.size} images:"
puts images = This is a title
Author Name
:icons: font
This a preamble
== This is a section
These are some replacements {value}
== Some admonitions
NOTE: Asciidoctor supports font-based admonition icons, powered by Font Awesome!
== A few images
A block image
image::images/sunset.jpg[]
An inlined image image:images/AsciiDoc-R-logo-color.png[] in the text. |
Inline images are cataloged (when catalog assets is enabled), but only while the document is converted to the output format. Thus, they won't be available until after the document is converted. That's because the |
Thank you very much for your responses. Indeed, calling Two thoughts on this where you could maybe help future users of the bindings:
|
Now I understand why the docs use
Everything makes sense from Asciidoctor (the Ruby core) point of view. The issue I see here is that AsciidoctorJ has two methods to do the same and they are not working (for me at least) and we have no tests 😞 var options = Options.builder()
.safe(SafeMode.SAFE)
.catalogAssets(true)
.build();
var doc = asciidoctor.convert(Files.readString(sourceDocument.toPath()), options, Document.class); Returns an internal Ruby String And this which I think should be good one returns null. var document = asciidoctor.convertFile(sourceDocument, options, Document.class); Once this is fixed, we can start thinking about how to better integrate with the maven plugin. @adrpar I presume you are using an extension? Do you mind opening an issue in github.com/asciidoctor/asciidoctor-maven-plugin/ with the specific use case and an example? |
I was not aware of the maven plugin and I need to check if it suites my needs. My use case is in general to implement a documentation workflow that is similar to what the docToolchain (https://doctoolchain.org) provides but more extensible and tailored to uploading documentation to Confluence. My idea was to create a set of command line tools that can be put together into a processing pipeline that will run within a CI/CD system. Specifically the use case for getting all the images was with copying the sources of a documentation into a "build" directory, so that all images are in one place. Thus collecting all images in one I hope that somewhat explained my use case. |
This would deviate from the behavior of Asciidoctor core and cause side effects, not something AsciidoctorJ should be doing. Right now, the contract in Asciidoctor is that the inline images become available after conversion. Thus, if you need to access them, then the code that calls Asciidoctor needs to use convert or convertFile. (This may change in the future major release once we solve the inline parsing issue, which we are working on. But it's not the way it is now). |
First of all, thanks for Asciidoctor and its Java bindings!
I am struggling with using the AST, as I would like to obtain all references to images in my document. I have understood that
findBy
is not able to find any inlined images, however from the issues and discussions around the Asset Catalog I got to understand (probably wrongly) that it would contain also inlined images when processing the source with the appropriate optioncatalogAssets
set totrue
.Is it possible using AsciidoctorJ to obtain the inlined images or do I need to process the individual blocks myself?
Thank you for your help.
The text was updated successfully, but these errors were encountered: