https://discuss.asciidoctor.org/Single-CSS-for-multiple-nested-adoc-files-tp552p556.html
Hey Christian,
Great question. I hadn't considered this scenario, so I'm glad you brought it forward. I really had to give it some thought.
Solution A ::
The simplest solution, naturally, is to embed the stylesheet into the document. This happens in Asciidoctor 0.1.4 by default (no linkcss or copycss flags).
$ asciidoctor '**/*.adoc'
Solution B ::
Another solution is to provide an absolute path to the stylesheet, assuming you are serving the documents from a webserver. In this case, you'd have to handle copying the stylesheet to where you want it manually.
$ asciidoctor -a stylesdir=/stylesheets -a linkcss -a copycss! '**/*.adoc'
However, those solutions may not match your requirements. Here are some that might.
Solution C ::
When you are running Asciidoctor once across a nested set of documents, it's currently not possible to specify a single relative path for the stylesdir attribute that would work for all documents, since the relative depth differs for documents in subdirectories. One way to solve this problem, as Jason suggested, is to maintain the path to the stylesdir in each document.
For 1.adoc and 2.adoc, that would be:
:stylesdir: ./stylesheets
For 3.adoc, that would be:
:stylesdir: ../stylesheets
Now the handling of the stylesheet and the reference in the document will behave as you expect.
Solution D ::
This got me thinking, though, that perhaps Asciidoctor should set an implicit attribute that passes the relative path from the document to the top-level when processing documents that span subdirectories. I'm thinking something like `docrootdir`. That way, the stylesdir attribute in the document is portable to where the document is placed.
:stylesdir: {docrootdir}/stylesheets
What do you think about that idea and, if we pursue it, the proposed name of the attribute. This would be a feature that is specific to Asciidoctor's ability to process documents in subdirectories. We could also set the same attribute in the Maven and Gradle plugins.
-Dan