B
Burke Libbey
While this is a rails-related question, it has more to do with ruby in
general.
The user selects a range by highlighting it. This is detected with
javascript and fed to ruby. I want to take this range and highlight it.
I'm doing that by adding <span class="anno"></span> around the region.
So that works ok, except that this often causes tag nesting problems.
What I want to do is intelligently add more tag pairs to preserve
nesting.
For example, the range:
this is a</span> test <strong>that <span>uses pretty</span>
bizarre</strong> markup.
Should become:
<span class="anno">this is a</span></span><span class="anno"> test
<strong>that <span>uses pretty</span> bizarre</strong> markup.</span>
I'm not looking for someone to write the code for me (although if you
did, I wouldn't complain); I just need someone to point me in the right
direction. Should I start from scratch with RegExes, or is there a
suitable library?
Thanks.
/burke
general.
The user selects a range by highlighting it. This is detected with
javascript and fed to ruby. I want to take this range and highlight it.
I'm doing that by adding <span class="anno"></span> around the region.
So that works ok, except that this often causes tag nesting problems.
What I want to do is intelligently add more tag pairs to preserve
nesting.
For example, the range:
this is a</span> test <strong>that <span>uses pretty</span>
bizarre</strong> markup.
Should become:
<span class="anno">this is a</span></span><span class="anno"> test
<strong>that <span>uses pretty</span> bizarre</strong> markup.</span>
I'm not looking for someone to write the code for me (although if you
did, I wouldn't complain); I just need someone to point me in the right
direction. Should I start from scratch with RegExes, or is there a
suitable library?
Thanks.
/burke