css.parser: Minimal CSS parser

Description Usage Arguments Value Note Author(s) References Examples

Description

Minimal CSS (Cascading Style Sheets) parser.

Usage

1

Arguments

file

file to parse

lines

lines of text to parse, read from file by default

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 :

1
2
3
4
.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 (see http://www.w3schools.com/css/css_colors.asp), 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.

Author(s)

Romain Francois <romain@r-enthusiasts.com>

References

http://www.w3schools.com/css/ http://www.w3schools.com/css/css_colors.asp

Examples

1
2
3
4
5
## Not run: 
cssfile <- system.file( "stylesheet", "default.css", package="highlight")
css.parser( cssfile )

## End(Not run)


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

Questions? Problems? Suggestions? or email at ian@mutexlabs.com.

Please suggest features or report bugs with the GitHub issue tracker.

All documentation is copyright its authors; we didn't write any of that.