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

Allow to specify multiple stylesheets #3471

Open
ggrossetie opened this issue Oct 31, 2019 · 1 comment
Open

Allow to specify multiple stylesheets #3471

ggrossetie opened this issue Oct 31, 2019 · 1 comment

Comments

@ggrossetie
Copy link
Member

Current behavior

Currently, it's only possible to define a single custom stylesheet using the stylesheet attribute.
For instance, the following command will use the stylesheet named custom.css:

$ asciidoctor -a stylesheet=custom.css sample.adoc

In this case, custom.css will replace the default Asciidoctor stylesheet.

New behavior

In order to promote, re-usability and composability, I think it could be useful to define multiple stylesheets.

Consider the following example:

$ asciidoctor -a stylesheet="themes/variables.css;client-y-variables.css;themes/dark.css" project-a.adoc
$ asciidoctor -a stylesheet="themes/variables.css;client-z-variables.css;themes/dark.css" project-b.adoc

In the above examples, we can override just a few variables in client-y-variables.css and client-z-variables.css while using the same dark theme.

Another use case would be to use the bundled Asciidoctor stylesheet, yet still be able to override some styles.
Similarly to Asciidoctor PDF, we could refer to the bundled stylesheet using the GEM_DATA_DIR constant:

$ asciidoctor -a stylesheet="GEM_DATA_DIR/stylesheets/asciidoctor-default.css;override.css" custom.adoc

This feature could be added at a later stage.

@ggrossetie
Copy link
Member Author

Since copycss can point to a stylesheet file, we should also support multiple stylesheets right? For instance:

-a copycss=variables.css;colony.css -a stylesheet=colony.css -a stylesdir=./styles

But what should we do if copycss contains multiples files but stylesheet contains a different number of files?
In the above case, we could infer that the user wants to copy variables.css and colony.css into a single file named colony.css (concat). But if we declare the following then the intent is unclear:

-a copycss=/path/to/a.css -a stylesheet=one.css;two.css -a stylesdir=./styles
-a copycss=/path/to/a.css;/path/to/b.css;/path/to/c.css -a stylesheet=one.css;two.css -a stylesdir=./styles

My proposal is to use copycss to resolve the location of the stylesheets in order. If the location is undefined (empty) then we should resolve the location as a file relative to the base directory.

So in the first example above, one.css location is /path/to/a.css and two.css location is undefined so two.css will be resolved as a file relative to the base directory.

It could also work when the file is not the last one:

-a copycss=/path/to/a.css;;/path/to/b.css -a stylesheet=one.css;two.css;three.css -a stylesdir=./styles

Here, one.css and three.css will be resolved using the path defined in copycss and two.css will be resolved as a file relative to the base directory since the location is undefined (empty).

In the second example, one.css and two.css will be resolved according to the path defined in copycss.
I think there's two possibilities for the extra location /path/to/c.css:

  • Ignore the (input) location since there's no (output) stylesheet
  • Concat the content into the previous (output) stylesheet

@mojavelinux What do you think?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant