-
Notifications
You must be signed in to change notification settings - Fork 98
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Parser generator? #12
Comments
Ah, interesting! Precisely yesterday I was looking for a CSS grammar/tokenizer... but also haven't done this before. Definitely check this out: http://zaach.github.com/jison/ |
isnt css lovely :) giant clusterfuck of inconsistencies. does cssom work with node? you should publish to npm |
CSS has a lot of crap that nobody uses anyway (@page, @top-left-corner, ...). Yes, it does work with node. Although, I haven't bothered yet to run tests on Node (I run them in the browser). I'll publish it to npm today. |
Published. npm install cssom. |
Was exploring this same possibility with. I want to be able to parse css files and mutate them. I.E:
"blue" # correctly overrides the initial red shorthand
"test.jpg" # gives me the image url rather than url('sdfas.jpg')
"background:url('awesome.jpg') red no-repeat; background-color:blue" # Serialize new css. Maintaining a similar structure isn't necessary. I.E. Expanding all shorthand properties would be okay too. Your project looks promising for this purpose. I'm reluctant to dive in because I've seen some massive implementations (jscssp) that would need to be tweaked to create a nice object model. Then potentially you have to keep up with the spec. They state this might not be the best idea since (antlr at least) "does not express parsing conventions, only syntax." |
Basically a live CSS editor. You have various page elements (defined by selectors) and you can edit the CSS of each one. The interface needs to be able to read the CSS and load the values into a user interface (i.e. modify border thickness with a jQuery ui slider). The UI manipulates the values, then exports a new stylesheet. The styles you're manipulating don't necessarily appear on the page where the css editor is present. One of the possibilities I've explored is simply using the DOM and jQuery's css function. The problem here is that if you don't have a document that matches your css selectors, the values will be undefined. This hack might work if you generate temporary doms for each CSS rule you encounter - which should be less tricky than parsing css. I.E. css: There's certain caveats. You'd have to isolate this DOM somehow so that other styles in your website don't interact, but that's what the unique id could be used for. You prefix the selectors accordingly and inject them into your document. |
You can access a stylesheet via My old take on CSS editor. |
It seems feasible to use some parser generator and reuse WebKit's stuff
http://svn.webkit.org/repository/webkit/trunk/WebCore/css/tokenizer.flex
http://svn.webkit.org/repository/webkit/trunk/WebCore/css/CSSGrammar.y
Never did it before. Any pointers?
The text was updated successfully, but these errors were encountered: