views:

102

answers:

2

How can one insert a Unicode string CSS into CleverCSS?

In particular, how could one produce the following CSS using CleverCSS:

li:after { 
   content: "\00BB \0020";
}

I've figured out CleverCSS's parsing rules, but suffice that the permutations I've thought sensible have failed, for example:

li:
   content: "\\00BB \\0020" // becomes content: 'BB 0'

EDIT: My other examples and the rest of my post weren't saved. Suffice to say that I had a longer list of examples that's missing.

I'd be grateful for any thoughts and input.

Brian

EDIT: I noted that inserting the unicode was one of the problems (once you start uploading CSS with utf-8 encoding it's fine). The wrapping of quote characters is another, which I solved that with something crazy likeso:

content: "'".string() + " ".string() ».string() + "'".string()

Hope that helps someone else.

+1  A: 

In looking at the code (CleverCSS 0.1) it would appear that the partial regular expression _r_string (defined on line 414) is where you would need to start. This is used to define several other REs, including _string_re which is used in the parsing rules (line 1374). This leads us to process_string() (line 1359) which looks like it was meant to accept Unicode.

Unfortunately, hand-built parsers tend to get a bit strange and the code is not exactly swimming in comments. If you really need to do this, I would focus on process_string() and put a bunch of before/after print statements in there and see if you can understand the goes-intos and goes-outofs.

You might also try bribing the original author with beer or ??? Good luck.

Peter Rowell
Sounds like a headache. :) Thanks for the luck.
Brian M. Hunt
+2  A: 

This may be silly, but why still bother with escape sequences when you can just type/paste the actual characters? "A CSS style sheet is a sequence of characters from the Universal Character Set".

That is a lot easier on the eye, and is especially useful when maintaining existing code.

Or is CleverCSS not Unicode-enabled?

janmoesen
Good suggestion - I tried this, too. However, putting ' »' in the CleverCSS results in ' »' in the CSS. Not sure why.
Brian M. Hunt
Ah-ha. This works, but I had to put `Content-Type: 'text/css; ; charset=utf-8'` in the header for the CSS.
Brian M. Hunt