Previous Message
Next Message

[css-d] How to nest font color changes?

Sent by Brad Cox on 16 August 2002 21:09


I have a servlet-based tool for browsing java source code. (Click 
"Source" at the top of http://virtualschool.edu/jwaa and click any 
file name to see what I mean). The tool (currently) presents source 
lines as an <ol> list to generate line numbers, with each line 
emitted as <li>, plus a number of &nbsp; to reflect indentation. Ok 
so far, unless someone can suggest a better way. That's not the main 
problem.

The problem is that I want the tool to color-code the text to reflect 
a number of things (comments, strings, etc), but most importantly, 
the nesting level of two digraph pairs that commonly appear in my 
code (which are eventually converted to ordinary java strings by a 
preproprocessor). Everything within even-level {{...}} delimiters 
(including zeroth) should display in one font color (typically black) 
and everything in odd-level {{...}} delimiters should display in 
another.

The code for computing this isn't the problem... that's already in 
place (see JwaaBrowse.j via the browser mentioned above, commented 
out right now). The problem is with the CSS that the code is 
emitting. Here's what its emitting now (caution: hand-built example). 
The black and red text indicates the hoped-for results:

<ol>
<li>Black black black <span class="even">{{ Red red red</li>
<li>Red red red <span class="odd">{{ Black black black </li>
<li>Black black black <span class="even">{{ Red red red </li>
<li>Red red red <span class="odd">{{ Black black black </li>
<li>}} Black black black </span>Red red red</li>
<li>}} Red red red </span>Black black black</li>
<li>}} Black black black </span>Red red red</li>
<li>}} Red red red </span>Black black black</li>
</ol>

The actual results are that the color changes only persist to the end 
of the line, I think because <li> resets them internally. Can someone 
point out what I doing wrong and how to get the hoped-for results?
-- 
Brad Cox, PhD; [EMAIL-REMOVED] 703 361 4751
o For industrial age goods there were checks and credit cards.
    For everything else there is http://virtualschool.edu/mybank
o Java Web Application Architecture: http://virtualschool.edu/jwaa
o Ruby Interactive Learning Environment http://virtualschool.edu/ile
Previous Message
Next Message