asciidoctor / asciidoctor-pdf

:page_with_curl: Asciidoctor PDF: A native PDF converter for AsciiDoc based on Asciidoctor and Prawn, written entirely in Ruby.
https://docs.asciidoctor.org/pdf-converter/latest/
MIT License
1.14k stars 500 forks source link

Error using seemingly valid custom color variables #2195

Closed qay21 closed 2 years ago

qay21 commented 2 years ago

Hi, I'm having a hard time defining custom variables for colors. I'm curently using this at the very top of my theme file :

brand:
  primay_color: 'f39100'
  secondary_color: '71b85d'

Later in the theme file, I'm using these variables as such :

heading:
  h1_font_size: floor($base_font_size * 2)
  h1_font_color: $brand_primary_color
  h2_font_size: floor($base_font_size * 1.5)
  h2_font_color: $brand_secondary_color

However, since the moment I added these custom brand_ variables (originally named after my company, but I renamed it while doing trial&error hoping to find what's wront), I have this error :

asciidoctor: WARNING: unknown variable reference in PDF theme: $brand_primary_color
Unknown type of color: "$BRAND"

I have browsed old issues here and there, it seems the color definition might have been tricky in the past, due to how YAML is processed regarding # and such. However I think I'm here using a perfectly valid definition, according to the themng guide.

Do I miss something here ?

mojavelinux commented 2 years ago

One inconsistency I see is that you are using underscores instead of hyphens to separate key segments. While that's not likely the problem here, that is a practice we now recommend.

I tested the following theme with Asciidoctor PDF 2.0.0 and it works without issue:

extends: default
brand:
  primary-color: 'f39100'
heading:
  h1-font-color: $brand-primary-color

Likely I would need to see more of the theme to know what the problem might be.

In the future, please ask for help in the project chat at https://chat.asciidoctor.org (specifically in the users/asciidoctor-pdf stream). To help make the project easier to manage, we don't open issues until we have verified that there is actually a problem with the code.