Next: , Up: The --style option   [Contents][Index]


2.6.1 Creating your own style files

The same style file can be used for styling a certain type of output, for terminal output and for HTML output. It is written in CSS (Cascading Style Sheet) syntax. See https://www.w3.org/TR/css2/cover.html for a formal definition of CSS. Many HTML authoring tutorials also contain explanations of CSS.

In the case of HTML output, the style file is embedded in the HTML output. In the case of text output, the style file is interpreted by the libtextstyle-enabled program.

You should avoid @import statements, because

CSS rules are built up from selectors and declarations. The declarations specify graphical properties; the selectors specify when they apply.

GNU libtextstyle supports simple selectors based on "CSS classes", see the CSS2 spec, section 5.8.3. The set of CSS classes that are supported by a libtextstyle-enabled program are documented in the documentation of that program.

These selectors can be combined to hierarchical selectors. For example, assume a program supports the CSS classes string (that matches a string) and non-ascii (that matches a word with non-ASCII characters), you could write

.string .non-ascii { color: red; }

to highlight only the non-ASCII words inside strings.

In text mode, pseudo-classes (CSS2 spec, section 5.11) and pseudo-elements (CSS2 spec, section 5.12) are not supported.

The declarations in HTML mode are not limited; any graphical attribute supported by the browsers can be used.

The declarations in text mode are limited to the following properties. Other properties will be silently ignored.

color (CSS2 spec, section 14.1)
background-color (CSS2 spec, section 14.2.1)

These properties are supported. Colors will be adjusted to match the terminal’s capabilities. Note that many terminals support only 8 colors.

font-weight (CSS2 spec, section 15.2.3)

This property is supported, but most terminals can only render two different weights: normal and bold. Values >= 600 are rendered as bold.

font-style (CSS2 spec, section 15.2.3)

This property is supported. The values italic and oblique are rendered the same way.

text-decoration (CSS2 spec, section 16.3.1)

This property is supported, limited to the values none and underline.


Next: , Up: The --style option   [Contents][Index]