- From: Brad Kemper <brkemper@comcast.net>
- Date: Thu, 15 Nov 2007 10:00:58 -0800
- To: James Elmore <James.Elmore@cox.net>
- Cc: www-style Style <www-style@w3.org>
On Nov 15, 2007, at 9:16 AM, James Elmore wrote:
> I suggested something similar a year back and was told that "that
> is not format, it is content." I agree with you that it would be
> very useful to be able to format based on strings or other, more
> complex pattern matches. I couldn't find my original email in the
> archives, perhaps it was before I joined the group, so I will copy
> some of it here so it gets archived.
>
> I was considering the basic function of CSS (formatting HTML/XHTML/
> etc. content) and found an area where CSS is lacking: formatting
> based on content. Simple examples:
>
> If a number is negative, print it in red.
> If a name (IBM) appears in a page, make the font larger and bold.
> Display all (American) monetary values with a dollar sign ($), a
> decimal point (.) and cents ("$f8.2" for example).
>
Perhaps the dollars and cents example caused a negative reaction, as
folks here like the HTML to contain the the meaningful content, and
the lack of a dollar sign and decimal would make it less so. But your
other examples are no less valid (philosophy-wise) than ::first-line
or ::first-letter.
> There are plenty of regular expression libraries/packages
> available, so the hardest part of implementation could use one of
> these. The rest depends on how much freedom/power to provide users.
> Do we want to limit to just strings, or provide strings plus some
> special characters (start and end of word, e.g., from your example)
> or allow a full regular expression parser? I would guess the group
> would not want the latter, but what would the users want?
Full-on regular expression, including perl extensions, back
references and such, would probably be too expensive and complex. I
would favor a limited sub-set of regular expressions, with the
minimum (besides literals) being "\b" (word boundary), "\d" (digits),
"\w" (word character), and some sort of wild card (a period in
regular expressions). And I would want a space to match any
whitespace character (\s). Ranges and repetition subpatterns would
also be nice ( [A-Za-z0-9]+ for instance).
> I really think this would make CSS into a powerful formatting tool,
> allowing users to specify something like:
>
> body:equals("\wIBM\w") { font-size: +1; font-weight: bold; }
>
> Where one line of CSS can replace many <span
> class="CompanyLogo">IBM</span> insertions. Again, yes -- this can
> be done server side, with programming or macros. But it seems to be
> a powerful formatting ability and a natural fit for CSS.
>
Actually, I think you would want \b instead of \w there. \w matches
word characters, and \b is for boundaries of words.
Received on Thursday, 15 November 2007 18:01:12 UTC