]> mj.ucw.cz Git - leo.git/blobdiff - css-parse.y
Inline styles can be specified in object tags
[leo.git] / css-parse.y
index d5a775781472577f4867a620166e00ca8585f5a5..33293217ddad9f66feffc3f0cf64000a06f2310c 100644 (file)
@@ -48,6 +48,7 @@ static void css_add_to_val_list(struct style_prop *list, struct style_prop *elt)
 }
 
 %token LE GE NE CC
+%token SINGLE_PROP
 %token <s> NUMBER IDENT QUOTED RGB
 
 %type <s> ident_or_quoted
@@ -62,8 +63,13 @@ static void css_add_to_val_list(struct style_prop *list, struct style_prop *elt)
 %%
 
 input:
+    input_css
+  | prop_single
+  ;
+
+input_css:
     /* empty */
-  | input rule { clist_add_tail(&css_this->rules, &$2->n); }
+  | input_css rule { clist_add_tail(&css_this->rules, &$2->n); }
   ;
 
 rule_start:
@@ -280,6 +286,15 @@ prop_value_list:
       }
   ;
 
+prop_single:
+    SINGLE_PROP prop_value
+      {
+       struct style_prop *p = css_alloc(sizeof(*p));
+       css_this->parsed_prop = p;
+       *p = $2;
+      }
+  ;
+
 ident_or_quoted: IDENT | QUOTED ;
 
 %%
@@ -302,3 +317,23 @@ struct css_sheet *css_load(char *filename)
   css_this = NULL;
   return ss;
 }
+
+struct style_prop *css_parse_prop(struct mempool *mp, char *objname, const char *key_str, const char *value_str)
+{
+  struct css_sheet ss = {
+    .pool = mp,
+    .filename = objname,
+    .pushed_token = SINGLE_PROP,
+  };
+  clist_init(&ss.rules);
+
+  css_this = &ss;
+  css_lex_string(value_str);
+  css_parse();
+
+  struct style_prop *p = ss.parsed_prop;
+  p->key = style_prop_encode(key_str);
+
+  css_this = NULL;
+  return p;
+}