Forum Feature requests

Custom colors like custom font-family declarations

kmmv
It's awesome that Prince supports custom font families (tip for others: it's a great way to separate your fonts into one location without relying on strictly sans-serif or serif fonts!):

@font-face {
  font-family: body-text;
  src: local("Times");
}
report > body {
  font-family: body-text;
}


however, it would be nice if Prince allowed custom colors in a similar fashion. Something like:

@color accent {
  color: #717171;
}
report > cover > title {
  color: accent;
}


I'm sure I'm not the only one that hates repeating myself. Having 6 identical color declarations elsewhere is error prone, and specifying all the rules in one location to apply a single color: declaration isn't nice, either, since it makes you use a single CSS file and you would need separate declarations anyway per color application (border, color, background, etc).
mikeday
In the past people have suggested adding a generic macro facility to CSS, to make it easier to share common definitions across multiple style rules. These proposals have all been rejected by the CSS working group for various reasons, but perhaps it would be useful to implement one and get some practical experience with it. (The resulting CSS would be Prince-specific and would not work in web browsers, which does limit its usefulness).

For example:
@prince-define body-text "Times";
@prince-define accent #717171;

It might also be necessary to wrap up defined symbols in a special function rather than using them as-is, to avoid confusion with existing CSS keywords:
title { color: prince-use(accent) }