Hasty Briefsbeta

Bilingual

Beej's Bit Bucket

a day ago
  • CSS lacks variables, leading to hard-coded constants like theme colors that are difficult to maintain.
  • m4 is a macro processor that can substitute strings, enabling easy updates to CSS values.
  • Basic usage: define a macro with `define(`NAME', `value')` and use it in CSS; run `m4 file.css.m4 > file.css`.
  • Quoting in m4 uses backtick (`) as open and apostrophe (') as close to prevent macro expansion.
  • The `dnl` directive deletes the newline after a define line to avoid extra blank lines in output.
  • Parentheses after macro names (e.g., `THEMECOLOR()`) allow macros to be placed adjacent to other text.
  • External files can be included via `include()` or `sinclude()` for modular CSS.
  • Integer math is possible with `eval()`, e.g., `eval(XPOS + 40)` for computed positions.
  • m4 can also be used for HTML, but caution is needed due to lack of multibyte support and potential complexity.
  • Other CSS-specific tools like Less and Sass exist, but m4 is lightweight, POSIX-compliant, and widely available.