@facelessuser: I came across encode() the other day and was considering 'xmlcharrefreplace', although I wasn't sure how it fitted in to the project. The Python docs don't indicate that encode() takes varargs - must be out of date.
BTW, and out of interest, I conquered adding comments last night (in my head
). Here's my outline, but I'm not sure if it's worth doing. Nevertheless, it's interesting
1. Create a shortcut to store the current view, point, word under the point - and a comment read from the input panel - in a dictionary of tuples, using the view as key. If there isn't a proper a-z word under the point, then bail, and it cannot be a selection (just a single point).Allowing a selection is too messy, as it would cover a number of spans. Similarly, extending the comment across the current span could be messy, particularly if within a comment line. (Why would someone put a comment in a comment, Doh!)
2. Add CSS rule(s) to a tag such as 'b' or 'tt', or possibly a little bit of JS, based on a class that would create the tooltip on hover. (JS might use ids instead: e.g. 'comment' + pt)
2b. Format the tag so it stands out. Can't really use a colour, so perhaps underline or italic. (But perhaps allow yet another setting for 'comment_colour'.)
2c. Might need another styled-span, that JS would use to display the tooltip.
3. During parsing of the lines/spans - but after entity escaping the HTML - examine the comment-points to see if any fall within the current region/span.
4. If so, compare the word-under-point. If it's not the same, then bail - they've added more code and the comment is no longer relevant.
5. Find the same word in tidied_text, and replace it with '<b class=\"comment\" title=\"The comment text\">word</b>
6. If using JS for the tooltip, would need to insert the (new) styled-span just inside this b-tag, containing the comment text. (It could be positioned to display underneath the line.)
I recall/believe that tooltips can be created with just CSS, particularly CSS3. They could even just be <a> links, but a little JS might be better.
Anyway, I haven't decided how far I might pursue this. Although, it's still kinda cool
I shall have a look at your current work in a while. Regards, Andy.
"I'm here to save your life. But if I'm going to do that, I'll need total uninanonynymity." Me Myself & Irene.