\csstidy
CSS Parser class
This class represents a CSS parser which reads CSS code and saves it in an array.
In opposite to most other CSS parsers, it does not use regular expressions and
thus has full CSS2 support and a higher reliability.
Additional to that it applies some optimisations and fixes to the CSS code.
An online version should be available here: http://cdburnerxp.se/cssparse/css_optimiser.php
- Author: Florian Schmitz (floele at gmail dot com) 2005-2006
Synopsis
class csstidy
{
- // members
- public array $css = ;
- public array $tokens = ;
- public $print;
- public $optimise;
- public string $charset = '';
- public array $import = ;
- public string $namespace = '';
- public string $version = '1.3';
- public array $settings = ;
- public string $status = 'is';
- public string $at = '';
- public string $selector = '';
- public string $property = '';
- public array $sel_separate = ;
- public string $value = '';
- public string $sub_value = '';
- public array $sub_value_arr = ;
- public string $str_char = '';
- public string $cur_string = '';
- public string $from = '';
- public boolean $str_in_str = false;
- public bool $invalid_at = false;
- public bool $added = false;
- public array $log = ;
- public integer $line = 1;
- // methods
- public void csstidy()
- public mixed get_cfg()
- public bool set_cfg()
- public void _add_token()
- public void log()
- public string _unicode()
- public void load_template()
- public void parse_from_url()
- public void is_token()
- public bool parse()
- public void explode_selectors()
- public bool escaped()
- public void css_add_property()
- public void merge_css_blocks()
- public bool is_important()
- public string gvw_important()
- public bool property_is_next()
- public bool; property_is_valid()
Members
public
- $added
—
bool
=true if something has been added to the current selector - $at
—
string
Saves the current at rule (@media) - $charset
—
string
Saves the CSS charset (@charset) - $css
—
array
Saves the parsed CSS - $cur_string
- $from
—
string
Status from which the parser switched to ic or instr - $import
—
array
Saves all @import URLs - $invalid_at
—
bool
=true if in invalid at-rule - $line
—
integer
Saves the line number - $log
—
array
Array which saves the message log - $namespace
—
string
Saves the namespace - $optimise
—
Optimiser class - $print
—
Printer class - $property
—
string
Saves the current property - $sel_separate
—
array
Saves the position of , in selectors - $selector
—
string
Saves the current selector - $settings
—
array
Stores the settings - $status
—
string
Saves the parser-status. - $str_char
—
string
Saves the char which opened the last string - $str_in_str
—
string
Variable needed to manage string-in-strings, for example url("foo.png") - $sub_value
—
string
Saves the current sub-value - $sub_value_arr
—
array
Array which saves all subvalues for a property. - $tokens
—
array
Saves the parsed CSS (raw) - $value
—
string
Saves the current value - $version
—
string
Contains the version of csstidy
Methods
public
- _add_token() — Adds a token to $this->tokens
- _unicode() — Parse unicode notations and find a replacement character
- css_add_property() — Adds a property with value to the existing CSS code
- csstidy() — Loads standard template and sets default settings
- escaped() — Checks if a character is escaped (and returns true if it is)
- explode_selectors() — Explodes selectors
- get_cfg() — Get the value of a setting.
- gvw_important() — Returns a value without !important
- is_important() — Checks if $value is !important.
- is_token() — Checks if there is a token at the current position
- load_template() — Loads a new template
- log() — Add a message to the message log
- merge_css_blocks() — Adds CSS to an existing media/selector
- parse() — Parses CSS in $string. The code is saved as array in $this->css
- parse_from_url() — Starts parsing from URL
- property_is_next() — Checks if the next word in a string from pos is a CSS property
- property_is_valid() — Checks if a property is valid
- set_cfg() — Set the value of a setting.