views:

115

answers:

2

Hi!

I have this idea, the user defines set of css rules with some comments (comments are simple annotations):

/* @name Page style */
body {
   font: 16px/1.5 Arial; /* @editable */
   backgorund-color: #fff; /* @editable */
}

/* @name Section header */
h1 {
   font: 20px/1.2 Arial; /* @editable */
   color: #c44 
}

I can apply this stylesheet to my page but I also want to parse this rules with the comments and provide some forms to edit these styles and let the user change the styles on the fly. These comments will indicate which rules/properties are editable.

I was looking for some browser or server solution. The easiest serwer solution would be to parse this css with some java css parser, convert it to ex. json and then make use of this json in the browser: http://www.featureblend.com/css-json.html

The problem is I haven't found any Java css parser which will be able to handle comments.

The same is in the browser, no suitable css parser. Any ideas how to do this?

A: 

You could write your own or maybe extend an existing one. It seems like you could match the editable values with a regular expression easily. Do you only want the editable values included in the object, or all values regardless?

tedmiston
+1  A: 

did you have a look at the css sac parser implementation?

http://www.w3.org/Style/CSS/SAC/

-->

http://www.w3.org/Style/CSS/SAC/doc/org/w3c/css/sac/Parser.html

the document-handler has a comment method

http://www.w3.org/Style/CSS/SAC/doc/org/w3c/css/sac/DocumentHandler.html#comment_java.lang.String_

phoet