Forum How do I...?

Adding replacing pairs to prince-text-replace

Jellby
Is it possible to add (not overwrite) "search-and-replace" pairs to a previously defined prince-text-replace property?

For instance, say a have a master .css file including:

body {
prince-text-replace: "mycolor" "green";
}

and for a specific document I want to also replace "myfruit" with "apple". If I don't want (or can't) modify the master .css, I cannot just use an additional .css file with:

body {
prince-text-replace: "myfruit" "apple";
}

because then occurrences of "mycolor" are not replaced with "green". Is there a way to have this second definition concatenated to the first?, i.e., make it as if I had said:

body {
prince-text-replace: "mycolor" "green" "myfruit" "apple";
}

If this is not currently possible, as it seems, it could be a nice extension to have.
mikeday
It is not possible, and this is due to the way that the CSS cascade works: every elements ends up with exactly one value for every property, and values cannot combine, one always wins.

This issue doesn't matter for most properties, as normally you don't want to combine them: you don't want "color: green" and "color: red" to combine and make "color: brown", you want the most specific selector to apply.

However, there are some properties where this would make sense, mostly those related to generated content, such as counter-increment / counter-reset, string-set, and prince-text-replace. Unfortunately there isn't a way to do this, it just requires care when writing your style sheets. Fortunately, these properties are fairly advanced, and normally only used in a few specific places in your style sheets that are easy to keep track.