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

Applying custom styles to source blocks #1486

Open
ggrossetie opened this issue Jan 14, 2020 · 8 comments
Open

Applying custom styles to source blocks #1486

ggrossetie opened this issue Jan 14, 2020 · 8 comments
Milestone

Comments

@ggrossetie
Copy link
Member

ggrossetie commented Jan 14, 2020

Let's say I want to write a Best Practices guide and I want to use a role on source blocks when it's not recommended. For instance:

Never enter passwords in plain text on the CLI:

[source.dont,sh]
----
$ mvn --encrypt-master-password P@ssw0rd

$ mvn --encrypt-password P@ssw0rd
----

In this case, I want to apply a custom style to highlight the fact that the reader should not do that.
Is that possible?

@mojavelinux
Copy link
Member

This is essentially the same as #483. There's currently no framework/callback in place to apply overrides from a role to a block. But the challenge is knowing what to override, what the precedence to apply, and which blocks support which properties.

@ggrossetie
Copy link
Member Author

ggrossetie commented Jan 14, 2020

But the challenge is knowing what to override, what the precedence to apply, and which blocks support which properties.

Maybe I'm missing something but I think the role should always have a higher precedence right?
Not sure about the other type of blocks but for a listing block I think we can support every properties that are available on a role: https://github.com/asciidoctor/asciidoctor-pdf/blob/master/docs/theming-guide.adoc#role

  • background-color
  • border-color
  • border-offset
  • border-radius
  • border-width
  • font-color
  • font-family
  • font-size
  • font-style
  • text-decoration
  • text-decoration-color
  • text-decoration-width

Do you want to implement this feature once for all type of blocks or can I submit a pull request to implement this feature only on listing blocks?

@mojavelinux
Copy link
Member

Yes, the role would win. But sometimes the key is figuring out where to merge the properties in time for the code to access them. Because sometimes the code goes straight to the theme and then it would end up undoing a previously overridden value. In other words, how the theme properties are accessed has to change.

@mojavelinux
Copy link
Member

I would like #483 to be implemented first, because it's the simpler of the changes. And then we can do listing blocks after that...going further if the design allows.

@graphitefriction graphitefriction added this to the future milestone May 16, 2022
@mojavelinux
Copy link
Member

I documented one way to accomplish this using an extended converter. See #959 (comment)

@mojavelinux
Copy link
Member

The technique for supporting roles per block type is now covered in the docs. See https://docs.asciidoctor.org/pdf-converter/latest/extend/use-cases/#theme-table-using-custom-role

@mojavelinux mojavelinux modified the milestones: future, v3.0.x Jun 27, 2022
@gemkod
Copy link

gemkod commented Mar 5, 2024

Hello,

(merci de m'indiquer si ce sujet doit faire l'objet d'un nouveau ticket ?)

What I can read concerns the extension of warning blocks. That's not what I'm looking for.

My goal is to be able to change the background and border colour of a -- delimited block based on the block type name:

[typeblock]
--
lorem ipsum dolor
--

I'm not restricted to using -- delimiters. But as these are "anonymous", I have chosen them.

I'd like to be able to apply a role to customise a block. I have read several tickets, including 483. Before reading them, I thought it wasn't possible, now I'm a bit confused.

Here's what I'd like to be able to do:

[skill]
--
* This is a simple sentence expressing a skill.
* This is another simple sentence expressing another skill
--
[todo]
--
* This is a simple sentence expressing a task to be done.
* This is another simple sentence expressing another task to be done
--
[question]
--
This is a question that can contain anything
--
[reply]
--
This is a response that can contain anything
--

I currently use the example block delimiter for my questions and customise the rendering as follows:

[question]
====
any content here
====

In my theme :

example:
background-color: #FBFAFC
border-color: #DDCDE6

For the answers, I use a sidebar block that I customise as follows:

[answer]
****
any content here
****

In my theme :

sidebar:
border-color: #B2D8B2
background-color: #F7FBF7

I use the example and sidebar delimiters so that I can customise the rendering. But that doesn't meet my needs, which go beyond these two cases.

I've read https://docs.asciidoctor.org/pdf-converter/latest/extend/use-cases/#theme-table-using-custom-role but I can't see anything that meets my needs.

How can I use roles in my case?

Thank you very much for your help. I love Asciidoc so much!

(I should point out that I only generate my materials in pdf format)

@mojavelinux
Copy link
Member

mojavelinux commented Mar 5, 2024

@gemkod please direct questions about usage to the project chat at https://chat.asciidoctor.org. Thanks.

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

4 participants