Stylesheet
==================================================================================
_Stylesheet_
==================================================================================
> (require (planet "parser.scm" ("soegaard" "stylesheet.plt")))
This library provides a parser for cascading stylesheets, a DrScheme
mode for editing style sheets and a stylesheet language.
Installing
----------
To install the stylesheet language in DrScheme just enter
(require (planet "parser.scm" ("soegaard" "stylesheet.plt")))
in an interaction window. The close DrScheme and open a new one. The
stylesheet language is now available in the language selection dialog
under experimental languages. Also in the "Modes" submenu of the
"Edit" menu the item "Stylesheet" is shown.
The Stylesheet Mode
-------------------
The _stylesheet mode_ features basic syntax highlighting.
The Stylesheet Language
-----------------------
In the Stylesheet language the "Run" button, checks the
syntax of the stylesheet, and if there is an error the
offending syntax will be highlighted.
The _Stylesheet Parser_
-----------------------
The parser parses CSS 2.1 according to the grammar:
<http://www.w3.org/TR/CSS21/grammar.html>
The following functions are exported:
> (parse-css-file filepath)
Parses the stylesheet in the given file and returns an AST.
> (parse-css-port port filename)
Parses the output of port as a stylesheet and returns an AST. The
filename is only used for error messages during lexing.
> (parse-string string)
Parses the given string as a stylesheet and returns an AST.
> (unparse-css ast)
Writes the stylesheet represented by the ast to the
current-output-port.
> (unparse-css-to-string ast)
Returns a string with a stylesheet represented by ast.
The ast is represented by the following structures.
STRUCTURE FIELDS
css:stylesheet charset imports ruleset/media/page
css:import address mediums
css:media mediums rulesets
css:medium name
css:page pseudo-page declarations
css:pseudo-page name
css:ruleset selectors declarations
css:selector simple-selector combinators
css:combinator combinator simple-selector ; a combinator and its right selector(s)
css:simple-selector name components ; the universal selector is represented as * for name
; components is a list of attribute selectors, ID selectors or pseudo classes
css:class name
css:attrib type name value ; type is simple, exact, paritial, lang
css:pseudo name argument ; arg: #f=normal ()=function w. no arg (name)=function with one arg
css:id name
css:declaration property expr important ; important is a boolean
css:empty-declaration
css:expr term operators
css:term term
css:operator operator term
css:unary-operator operator term
css:function name arg
Keywords: _css_ _parser_ _mode_ _stylesheet_