Closed Bug 574516 Opened 14 years ago Closed 14 years ago

Improve the highlighting algorithm to not add spans inside each other

Categories

(Tree Management Graveyard :: TBPL, defect)

x86
macOS
defect
Not set
normal

Tracking

(Not tracked)

RESOLVED FIXED

People

(Reporter: ehsan.akhgari, Assigned: ehsan.akhgari)

References

Details

Attachments

(1 file)

Attached patch Patch (v1)Splinter Review
philor pointed out to me that the new highlighting code on tbpl can inject nested <spans>.  For example, let's say we have this in some phase of the algorithm: <span class="highlight">foo</span>, and the next token is "t".  The result would be:

<span class="highligh<span class="highlight">t</span>">foo</span>

Not pretty.

This patch changes that algorithm to take nesting into account for both tags and entities.  The trick is the inTag function, which basically takes the part of the string preceding an index, and makes sure the number of start tokens (such as <) is not higher than the number of end tokens (such as >).
Attachment #453923 - Flags: review?(mstange)
Comment on attachment 453923 [details] [diff] [review]
Patch (v1)

>+          return prePart.split(start).length > prePart.split(end).length;

Very creative!
Attachment #453923 - Flags: review?(mstange) → review+
Assignee: nobody → ehsan
Status: NEW → ASSIGNED
(In reply to comment #1)
> (From update of attachment 453923 [details] [diff] [review])
> >+          return prePart.split(start).length > prePart.split(end).length;
> 
> Very creative!

Yeah, I have my days!  ;-)

http://hg.mozilla.org/users/mstange_themasta.com/tinderboxpushlog/rev/9a6588ffe785
Status: ASSIGNED → RESOLVED
Closed: 14 years ago
Resolution: --- → FIXED
Product: Webtools → Tree Management
Product: Tree Management → Tree Management Graveyard
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: