-
Notifications
You must be signed in to change notification settings - Fork 499
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
Theme custom variables are not taken into account in all places of the theme file #381
Comments
The problem/limitation here is with how we process hex color values. In YAML, the What's happening in your case is that YAML is seeing: brand:
red: As a result, your link color ends up black. If you want this to work, you have to either add brand:
red_color: #FF0000 or you need to use the quoted form so that YAML won't drop the value: brand:
red: 'FF0000' I suppose we could modify the preprocessor so that it also looks for key names that have |
I added this information the theming guide. See https://github.com/asciidoctor/asciidoctor-pdf/blob/master/docs/theming-guide.adoc#custom-variables |
Dan, thank you for describing how it work under the hood. There is a small issue with the newly added information, "#" symbold is not rendered correctly: " since -># is missing<- is the comment". It looks like to support ability to define colors in hex form, semantics of certain elements of YAML format was changed/broken. I'm not sure that it's good approach as YAML format is not used in the form/way as it's supposed to. Example of potential consequences: can't edit and validate asciidoctor-pdf theme file in IDEs or YAML validation tools (like yamllint). I would propose the following strategy:
What do you think? |
- preprocess all hex color values, regardless of key name - update documentation to make the syntax variants more clear
- preprocess all hex color values, regardless of key name - update documentation to make the syntax variants more clear
@AlexanderZobkov I just sent a pull request to make the preprocessing of hex color values much more robust. See #382. With this change, the theme reader will be able to handle all values regardless of the key names and will honor inline comments that follow the value.
Correct. This was done to make the file feel more comfortable for designers (and people familiar with CSS, LESS, Sass, etc).
The theme file is not technically YAML format (since we also have inline variables). It is YAML-like, but it is also CSS-like (or, more accurately, LESS). We made the decision to take this approach to bridge the gap between the worlds of programming and design. Eventually, we may move to a custom parser and drop the use of YAML under the covers (so it's more CSS like, or at least, more like LESS or Sass). Having said that...
You have the choice of strictly adhering to YAML since, in the end, the file is being parsed by YAML.
The primary audience for the theming guide is a designer. For that reason, I like to encourage our custom style by default. But I have made it clear in the guide that there are three ways of doing it and why you would choose each.
These are the recommended styles if you want to be YAML friendly. Let's call them the developer styles.
In fact, YAML will mangle the value in many cases (because YAML reads it as a number if it contains only digits). That's one of the main reasons we introduced the leading In the end, we need to allow all the forms, but I will make it clear in the guide that there are three options and why they exist. |
Alright, intention is clear now. I hope it will be handled correctly with #382. |
resolves #381 preprocess all hex color values
Indeed, you will need to use master (just merged) or wait for next alpha. |
I'm trying to use theme custom variablies feature to define re-usable values (brand colors, in my case).
By one of the colors I would like to define/change color of "link" elements.
If a color for "link" elements is defined via theme custom variables, defined color (let's say, red) is not taken into account and default color (black) is applied.
Probably other formatting elements are also affected by the issue.
It's easily reproducible on https://github.com/asciidoctor/asciidoctor-maven-examples/tree/master/asciidoctor-pdf-with-theme-example
Details:
custom-theme.yml
brand:
red: #FF0000
link:
font_color: $brand_red -> NOK, default color will be applied during PDF generation
...
link:
font_color: #FF0000 -> OK, specified color will be applied during PDF generation
The text was updated successfully, but these errors were encountered: