Raynes / refheap

The Reference Heap. A Clojure pastebin powered by Compojure, MongoDB, and Pygments.
129 stars 30 forks source link

Highlight the line number that is anchored #29

Closed Raynes closed 12 years ago

Raynes commented 12 years ago

You can anchor to line numbers if you want to point someone at a specific part of your code. However, if your paste is so short that the whole thing fits in the window or the line number you're anchored to is near the top, there will be no visible cues as to which line number you're pointed to. You'd have to look at the URL and then look for that line. We don't have to make things complicated and highlight the whole line (I'm not sure if that's even feasible with Pygments). As a matter of fact, I don't want to. I think it'd be really cool to highlight the actual line number itself. That should be easy to do with a little Javascript. We can make it some bright color that sticks out.

amcnamara commented 12 years ago

It is doable but kinda nasty due to the generated markup, basically there are a bazillion spans covering each different highlighted character in the code being viewed, with interleaved anchors, you'd have to parse to find the anchor you want then crawl the elements between that anchor and the next line's anchor and modify the span to include some kind of .line-highlight class (or just modify the style attr directly). This may actually be easier to do on the server side and change the anchors to api links...

Raynes commented 12 years ago

I'm actually already working on this. This is easier than you think.