JSCSSP now has support for CSS Media Queries
JSCSSP is NOT based on regular expressions for parsing, making it robust and easily extensible.
It's very simple to use and manipulate, and can be used to write a CSS validator, filters or even CSS extensions for a given browser. Here is the whole code for the interactive demo below:
var source = document.getElementById("source"); var ss = source.value; var parser = new CSSParser(); var sheet = parser.parse(ss, false, true); var serialization = document.getElementById("serialization"); if (sheet) serialization.innerHTML = sheet.cssText(); else serialization.innerHTML = "";
You can edit the stylesheet in the textarea just below. Press on the "Parse and Reserialize" button to see how JSSCSSP handles it. Warning: JSCSSP is still a work in progress so please don't be too surprised if you hit a bug...
JSCSSP is called to parse the stylesheet and here's how JSCSSP reserializes it: