Is it possible add CSS at runtime?

manojdcoder
Posts: 63
Joined: Thu Oct 29, 2020 12:01 am

Is it possible add CSS at runtime?

Post by manojdcoder » Wed Jan 27, 2021 12:36 am

I noticed DITA and DocBook defines CSS for built-in profiling attributes, for example following is the CSS from DITA for audience

Code: Select all

*[audience] {
    border: 1px solid green;
  }
  *[audience]:after(1000003) {
    font-size: 0.75em;
    content: ' (if audience is ' oxy_label(text, oxy_concat("'", oxy_replace(attr(audience), ' ', "' or '"), "'"), color, #0000ff) ') ';
    background-color: #CCFFAA;
  }
I have a dynamic list of profiling attributes for which I like to add similar CSS. Is it possible to inject CSS into editor at runtime using plugin, perhaps right before loading the document?

manojdcoder
Posts: 63
Joined: Thu Oct 29, 2020 12:01 am

Re: Is it possible add CSS at runtime?

Post by manojdcoder » Thu Feb 04, 2021 5:39 am

Any update here?

cristi_talau
Posts: 329
Joined: Thu Sep 04, 2014 4:22 pm

Re: Is it possible add CSS at runtime?

Post by cristi_talau » Fri Feb 05, 2021 12:03 am

Hello,

Web Author supports custom DITA profiling attributes by default. The DITA specialization has to declare them using the domains attribute of the root element. This attribute should contain:

Code: Select all

a(props ATTR)
where ATTR is the name of the custom profiling attribute.

A more flexible option is to use the StylesFilter API [1].

Depending on your use-case, using psuedo-classes [2] can also be an option.

Best,
Cristian

[1] https://www.oxygenxml.com/InstData/Edit ... ilter.html
[2] https://www.oxygenxml.com/doc/versions/ ... asses.html

Post Reply