GeSHi / geshi-1.1

Next generation of Generic Syntax Highlighter for PHP
http://qbnz.com/highlighter/
67 stars 13 forks source link

Add background and alpha support to the CSS parser #7

Closed Sei-Lisa closed 10 years ago

Sei-Lisa commented 10 years ago

Support background: <color> and background-color: <color>. The <color> can now be rgb(r, g, b) or rgba(r, g, b, a), as percentage or as a number from 0 to 255, according to the CSS3 specifications http://www.w3.org/TR/css3-color/#rgba-color and following the CSS2 grammar rules in http://www.w3.org/TR/CSS2/grammar.html

Changes the semantics of _parseColor so that it can return an array partially filled, to allow the missing elements to be filled from defaults (e.g. if there's no alpha specified, it's not returned) and not from its own default. Additionally, now it returns false to indicate parse failure. Currently, the only caller (_parseCSS) deals with a parse error by using the default color, so it's equivalent to returning an empty array, but the new semantics would allow for example to issue a warning, should that mechanism exist.

Sei-Lisa commented 10 years ago

I'm going to start again. Please dismiss this PR.