1 ddc03123 2020-03-28 op The first version of this website had a theme switcher. It was
2 ddc03123 2020-03-28 op implemented with CSS variables (and a bit of javascript). Then the
3 ddc03123 2020-03-28 op javascript switcher was eventually removed, and the theme forced to be
4 ddc03123 2020-03-28 op dark, but I kept the CSS variables *just in case* (read: I'm lazy.)
6 ddc03123 2020-03-28 op *Edit*: this is no longer the case. The current version of the website
7 ddc03123 2020-03-28 op is *yet another one*, with a 100% rewritten (and pure) CSS.
9 ddc03123 2020-03-28 op The real reason I left the CSS variables was that I didn't wanted to
10 ddc03123 2020-03-28 op use a CSS preprocessor (such as `less` or `sass`) to manage such a
11 ddc03123 2020-03-28 op simple file (306 line, with blanks and comments). But, at the same
12 ddc03123 2020-03-28 op time, I didn't want to copy-paste the colors everywhere.
14 ddc03123 2020-03-28 op ## Introducing the C preprocessor
16 ddc03123 2020-03-28 op The C preprocessor is a simple and well-known beast (sort of, at
17 ddc03123 2020-03-28 op least), and it's included in the base system installation of most
18 ddc03123 2020-03-28 op (pratically all, I presume) OSes.
20 ddc03123 2020-03-28 op If you have never used it, here's a quick howto.
22 ddc03123 2020-03-28 op You can define constants with
24 ddc03123 2020-03-28 op #define PI 3.141592653589793238462643383279502884197169
26 ddc03123 2020-03-28 op and use them whenever you like, for instance
29 ddc03123 2020-03-28 op double p = PI / 4;
32 ddc03123 2020-03-28 op The preprocessor is more powerful, it supports `#include`s and
33 ddc03123 2020-03-28 op function-like macro (even variadic). But `#define`s are enough to
34 ddc03123 2020-03-28 op manage a couple of CSS variables.
36 ddc03123 2020-03-28 op Now, let's see how this applies to CSS. Given a file with the
37 ddc03123 2020-03-28 op following content
40 a3ab6f61 2020-09-22 op #define BASE1 #221635
43 a3ab6f61 2020-09-22 op background-color: BASE1;
47 ddc03123 2020-03-28 op we can *compile* it with
50 a3ab6f61 2020-09-22 op $ cpp -P file.css > a.css
53 ddc03123 2020-03-28 op and obtain a valid CSS file `a.css`.
55 ddc03123 2020-03-28 op ## Conclusions
57 ddc03123 2020-03-28 op It's weird. It's weird to invoke `cpp` to *build* a CSS files.
59 ddc03123 2020-03-28 op But it's also *satisfying*, in some sense.
61 ddc03123 2020-03-28 op As a conclusion, I would like to note that another option is to use
62 ddc03123 2020-03-28 op m4, a general purpose macro language that should be present on every
63 ddc03123 2020-03-28 op POSIX system. Unfortunately, I don't know the language very well, so I
64 ddc03123 2020-03-28 op opted to `cpp`.