css.parser: Minimal CSS parser

Description Usage Arguments Value Note

View source: R/css.R


Minimal CSS parser





file to parse


text lines to parse


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


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

	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 May 30, 2017, 6:45 a.m.

Search within the highlight package
Search all R packages, documentation and source code