css.parser: Minimal CSS parser

View source: R/css.R

css.parserR Documentation

Minimal CSS parser

Description

Minimal CSS parser

Usage

css.parser(file, lines = readLines(file))

Arguments

file

file to parse

lines

text lines to parse

Value

A list with one element per style class declaration. Each element is a list which has one element per CSS setting (color, background, ...)

Note

The parser is very minimal and will only identify CSS declarations like the following :

.classname{
	setting1 : value ;
	setting2 : value ;
} 

The line where a declaration occurs must start with a dot, followed by the name of the class and a left brace. The declaration ends with the first line that starts with a right brace. The function will warn about class names containing numbers as this is likely to cause trouble when the parsed style is translated into another language (e.g. latex commands).

Within the css declaration, the parser identifies setting/value pairs separated by : on a single line. Each setting must be on a seperate line.

If the setting is color or background, the parser then tries to map the value to a hex color specification by trying the following options: the value is already a hex color, the name of the color is one of the 16 w3c standard colors, the name is an R color (see colors), the color is specified as rgb(r,g,b). If all fails, the color used is black for the color setting and white for the background setting.

Other settings are not further parsed at present.


highlight documentation built on Jan. 22, 2023, 1:38 a.m.