The Highlighter does not returns that information when you use the methods getBestFragment. Behind the scene the Highlighter uses the TokenGroup class to get the start and the end index of each fragment. You could probably use that class.
+1
A:
Pascal Dimassimo
2010-05-13 19:37:19
actually, that hint was quite helpful. sorry for a really late response. Thanks
Umer
2010-08-20 10:16:24
A:
I did just that a few months ago. You have to build custom Formatter and Encoder. Basically, inside the highlighter, the formatter processes the tokens chosen for highlighting, while the encoder processes the rest of the tokens. In your case, you need the encoder to emit the empty each time it is called, and the formatter to emit the start index and the end index. They are indeed stored in the TokenGroup of the highlighted parts. Your highlighter should be constructed using these custom formatter and encoder.
Yuval F
2010-05-13 19:41:26