-1

Using this post, I created a variable in my file. Now I want to use it to define a background color in my array :

:first-color: #C0FFEE

[%noheader]
|===
h|{set:cellbgcolor:{first-color}} My Title
|{set:cellbgcolor} First cell
|===

But It did not work, all I have is an extra "}" in my title :

enter image description here

Is there a way to use variable to define my backgroung color ?

2 Answers 2

2

Since my previous answer may be useful in other contexts where CSS styling is supported, I'd rather not modify it and recommend a new solution. What do you think about creating a theme? Like in this YAML configuration file. You can name it my-theme.yml:

page:
  background-color: #ffffff

table:
  head:
    background-color: $first-color

base:
  font-color: #333333

Now, this is your asciidoc file:

:first-color: #C0FFEE

[%noheader,cols="100%"]
|===
h|My Title
|First cell
|===

And when converting to PDF, use the theme file:

asciidoctor-pdf -a pdf-theme=my-theme.yml your-file.adoc
Sign up to request clarification or add additional context in comments.

Comments

0

Does your output support CSS styling so you can maybe do something like this?

:first-color: #C0FFEE

[%noheader,cols="100%"]
|===
h|[.custom-bg]#My Title#
|First cell
|===

[source,css]
----
<style>
.custom-bg {
  background-color: #C0FFEE;
  display: block;
  padding: 5px;
}
</style>
----

1 Comment

I've try but it seems that my output does not support CSS styling. The source block appears in my pdf.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.