Next: , Up: Introduction   [Contents][Index]


1.1 Style definitions

Let’s look at the traditional way styling is done for specific programs.

Browsers, when they render HTML, use CSS styling.

The older approach to user-customizable text styling is that the user associates patterns with escape sequences in an environment variable or a command-line argument. This is the approach used, for example, by the GNU ‘ls’ program in combination with the ‘dircolors’ program. The processing is distributed across several steps:

  1. There is default style definition that is hard-coded in the ‘dircolors’ program. The user can also define their own definitions in a file such as ~/.dir_colors. This style definition contains explicit terminal escape sequences; thus, it can only be used with consoles and terminal emulators, and each style definition applies only to a certain class of mostly-compatible terminal emulators.
  2. The dircolors program, when invoked, translates such a style definition to a sequence of shell statements that sets an environment variable LS_COLORS.
  3. The shell executes these statements, and thus sets the environment variable LS_COLORS.
  4. The program looks at the environment variable and emits the listed escape sequences.

In contrast, this library implements styling as follows:

  1. There is a default style definition in a CSS file that is part of the same package as the stylable program. The user can also define their own definitions in a CSS file, and set an environment environment variable to point to it.
  2. The program looks at the environment variable, parses the CSS file, translates the styling specifications to the form that is appropriate for the output device (escape sequences for terminal emulators, inline CSS and <span> elements for HTML output), and emits it.

Thus, with GNU libtextstyle, the styling has the following properties:


Next: Built-in versus separate styling, Up: Introduction   [Contents][Index]