jelovirt / pdf-generator

DITA-OT PDF plug-in generator
https://dita-generator.elovirta.com/
Apache License 2.0
12 stars 5 forks source link

Styles based on outputclass #97

Open DavidMulder0 opened 1 year ago

DavidMulder0 commented 1 year ago

Is it possible to apply styles to for example notes with a specific outputclass?

Just playing around with the PDF theme functionality, and I have to say it's fantastic and it gets really far in providing all needed styling options without having to dive into XML. When publishing to HTML it's really easy to find people who know enough CSS to be able to style DITA output nicely, and I was looking at the PDF theme functionality to determine whether it would provide a 'similarly simple' type of control.

Looking at the xsl files I think the answer is no, but sadly my xsl knowledge is fairly limited atm. If the answer is no, would this be something that might be considered in the future?

jelovirt commented 1 year ago

One option would be to add a condition/if/predicate to a rule, something like

style:
  keyword:
    condition: .happy 
    color: orange

to style

<keyword outputclass="happy">CHEERS</keyword>

Ping @infotexture

infotexture commented 1 year ago

Interesting idea indeed, as it would allow styling elements that are not yet otherwise supported by the theme schema.

If this were to be implemented, we might want to consider key names or structures that make the connection to the @outputclass attribute more explicit (condition might be confusing).

Maybe something like this:

style:
  keyword:
    class: happy 
      color: orange
DavidMulder0 commented 1 year ago

Wouldn't both approaches however require an array somehow? Let's say we have two 'styles' of tables. One style of table is for huge tables full of data and with maybe smaller margins, etc.), another style of tables is for small tables. So you would need two table keys in the above syntax.

Worth considering: What if you want to style the title of a figure with a specific outputclass or an entry within a table with a specific outputclass.

The basic idea of CSS where you have an array of "selectors" (whatever the equivalent concept would be) and the properties you want to apply to matching elements is I think very strong. Something along those lines would I think be the 'holy grail'.