I’m trying to use the startStyle/endStyle options for the markText() function. However, when have overlapping marks, it appears that the endStyle is being placed on multiple spans for the mark.
I expected the rendered code to be something like this:
Thanks for the quick reply. I’m not sure if I understand completely so I’ll provide a little more detail.
I have text XXXYYYZZZ
There are two marks:
mark1 which covers all the text XXXYYYZZZ
mark2 which covers text in the middle YYY
CodeMirror renders that as: <span class="mark1">XXX</span><span class="mark1 mark2">YYY<span><span class="mark1">ZZZ</span>
On mark1 I add startStyle:“mark1-start” and endStyle:"mark1-end"
On mark2 I am not using start or end styles.
According to the docs endStyle would be “applied to the rightmost span that is part of the marker”, so I was assuming that it would appear on ZZZ, which is the rightmost span for mark1. Instead the endStyle is appearing on the first span XXX, not on the middle span YYY, and again on the last span ZZZ.
So in this case I can’t style the right side of the marked text, because the style is being applied in other places.
Argh, you already gave a link. Sorry about that. I figured out the issue – the test for whether a given span was the end of the mark was made before all other marks had been considered, and thus sometimes came out wrong. (Note the bug didn’t occur if you added the marks in another order.)