asciidoctor-maven-plugin’s preserveDirectories and relative links to CSS, icons, and images

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

asciidoctor-maven-plugin’s preserveDirectories and relative links to CSS, icons, and images

Andreas Sewe
CONTENTS DELETED
The author has deleted this message.
Reply | Threaded
Open this post in threaded view
|

Re: asciidoctor-maven-plugin’s preserveDirectories and relative links to CSS, icons, and images

abelsromero
Hi Andreas,

The resource management is always tricky. Files are converted one by one, and the maven plugin is just a wrapper to adjust and replicate the configuration for each file. Said so, I am afraid that what you need is not supported right now and cannot be done easily.
However, on the other hand, I can think of a few options that may help you:
1. (simple solution) Embedding the resources in the HTML: css and images can be embedded using embedAssets. This will increase the size of files, so deppending on your requeriments this can be a problem.
2. (complex solution) Split the configuration of each folder into differente executions, each one with the relative path to images, css, etc. But this, of course is not nice if you have several levels and can be a hell to mantain in the future.

Please, let me know if anything of this helps. I'm sorry I cannot be of more help.

Meanwhile, could you please share the configuration and a detailed example of your case? I cannot guarantee anything, but I'd like to give it a try and maybe I can implement what you want for a future release.


BTW, relativeBaseDir does not apply to your needs. It is used to deal with files in the source folder as 100% independent. Imagine you don't want to bother with paths, so you create several folders, each one with a css and images folders inside and several AsciiDoc sources. Setting relativeBaseDir to true allows you to reference the css or images to the relative path to where each AsciiDoc file is, that way you can move the files and reformat the folders anytime you want. If you don't set it, you'd have to reference the images with the relative paths from the root folder.
Reply | Threaded
Open this post in threaded view
|

Re: asciidoctor-maven-plugin’s preserveDirectories and relative links to CSS, icons, and images

Andreas Sewe
CONTENTS DELETED
The author has deleted this message.
Reply | Threaded
Open this post in threaded view
|

Re: asciidoctor-maven-plugin’s preserveDirectories and relative links to CSS, icons, and images

abelsromero
Sorry for not answering until now, too much work and too much flu lately.

Andreas Sewe wrote
OK, I have the classic src/main/asciidoc directory, along with a src/main/resources directory containing css, icons, and img directories. The asciidoctor-maven-plugin produces its results in target/generated-docs, the maven-resources-plugin produces its results in target/classes.

Anyway, what I seem to need is a way to prepend the appropriate number of ../ prefixes to my stylesheet and image references. If the asciidoctor-maven-plugin knew that its outputDirectory was one level above the css folder, it could adapt (for each of the calls to Asciidoc) the stylesheet path accordingly. Is this feasible or am I missing something?
I assume you're setting `imagesDir` property in the pom and the `stylesheet` attribute right?
In that case, my guts tell me it could be done, it will require some inelegant code though. The thing is validating if those propersties are set, then their values should be recalculated for each file.
In the following selected lines you can see how the target folder is calculated when preserveDirectories is set:
https://github.com/asciidoctor/asciidoctor-maven-plugin/blob/master/src/main/java/org/asciidoctor/maven/AsciidoctorMojo.java#L201-204

Something similar should be done in the same method to calculate the paths.

Sadly, right now I’m extremely busy and I won’t be able to attack this in some time, so if you want to have a look at it I'd be more than happy to help with anything I can, and merge the PR.