Re: Single CSS for multiple, nested adoc files

Posted by mojavelinux on
URL: https://discuss.asciidoctor.org/Single-CSS-for-multiple-nested-adoc-files-tp552p608.html

We need an issue to track this request. The issue should be named according to the requirement, not a particular solution. Something like:

"references to assets should remain consistent when processing documents in nested directories"

-Dan


On Sat, Sep 14, 2013 at 12:32 AM, Dan Allen <[hidden email]> wrote:
I also want to clarify that "docrootdir" does not have a direct correlation with any particular file. It's not the same, for instance, as "docdir". The "docrootdir" is a synthetic value that comes into existence when processing many files.

The "docrootdir" attribute is the path distance from the directory where the output file ends up and the output directory supplied to the invocation of Asciidoctor.

For example, if you run Asciidoctor recursively on:

src/main/asciidoc

and the output directory is

target/html

when this file is processed:

src/main/asciidoc/quickstart/quickstart-1.adoc

it ends up in

target/html/quickstart/quickstart-1.html

the docrootdir is ".."

-Dan


On Sat, Sep 14, 2013 at 12:24 AM, Dan Allen <[hidden email]> wrote:



On Thu, Sep 12, 2013 at 1:54 AM, ChrLipp [via Asciidoctor :: Discussion] <[hidden email]> wrote:

Solution E ::

- Copy the CSS manually.
- Link to the stylesheet with stylesdir and linkcss
- Provide an additional flag like useRelativeCssLinking which takes the adoc path and the css path and tries to compute a relative path. If this is possible, use it. If not, stick to the absolute path.

As I started to say in a previous response, the problem with something like useRelativeCssLinking is that this is not just an issue with CSS. The issue is with asset references in the output file.

I think we need to explore the following two solutions, and see which one plays out as most viable:

a. Provide a "docrootdir" attribute that can be used, perhaps in various ways, to keep the asset path consistent with the current directory level.
b. Recognize a relative directory for any attribute that ends with "dir" and adjust the value to reflect the current directory level

Instinct tells me that (b) is going to be very fragile and likely to confuse users that weren't on the design committee :) Although it seems like an extra step, using an attribute makes the intent very clear and gives us *lots* of room for doing smart things.

Now, we *could* still have a flag that implicitly adds "docrootdir" to the beginning of known asset path attributes, making it unnecessary to manually add the attribute...but under the covers it would still work as though it had been added explicitly.

-Dan



--



--
Dan Allen | http://google.com/profiles/dan.j.allen