Page 1 of 1

Is it possible add CSS at runtime?

Posted: Wed Jan 27, 2021 12:36 am
by manojdcoder
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?

Re: Is it possible add CSS at runtime?

Posted: Thu Feb 04, 2021 5:39 am
by manojdcoder
Any update here?

Re: Is it possible add CSS at runtime?

Posted: Fri Feb 05, 2021 12:03 am
by cristi_talau
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