3

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.

0

2 Answers 2

2
+100

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?

2
  • Good suggestion - I tried this, too. However, putting ' »' in the CleverCSS results in ' »' in the CSS. Not sure why. Mar 16, 2010 at 15:12
  • Ah-ha. This works, but I had to put Content-Type: 'text/css; ; charset=utf-8' in the header for the CSS. Mar 16, 2010 at 15:16
1

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.

1
  • Sounds like a headache. :) Thanks for the luck. Mar 9, 2010 at 16:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.