rupa / sprunge

command line pastebin for google appengine
http://sprunge.us
724 stars 70 forks source link

[Feature] Line highlight #11

Open franciscolourenco opened 10 years ago

franciscolourenco commented 10 years ago

You can already specify a line to jump to automatically.

This issue is for the implementation of the highlighting of that line, like github does.

Thanks

rupa commented 10 years ago

we use the pygments library for highlighting - if it supports that I'd be open to it, especially in a pull request.

mtahmed commented 10 years ago

pygments does support it but the browsers don't actually send the anchor part (the part after '#') to the HTTP server. So in other words, it's possible with either query_string (or some JS hackery to send the anchor to the server, although I don't like this option at all).

So there are two options:

Oblomov commented 10 years ago

This should be possible by replacing the lineanchors=n option to the HtmlFormatter with linespans=n and adding a rule such as :target { background-color: yellow } (or whatever) to the CSS. The :target selector might not work in IE < 9, but aside from that it's almost universally supported.

mtahmed commented 10 years ago

Ooooh! Didn't think of that! Clever solution. Question: Where would we add the :target CSS then?

Oblomov commented 10 years ago

Hm there doesn't seem to be a trivial way to customize the CSS styles generated by Pygments. I can't think of a trivial way of doing this 8-/

mtahmed commented 10 years ago

Maybe instead of generating CSS every time, just use pre-compiled CSS file and use the cssfile and noclobber_cssfile arguments to the formatter and add the desired :target ... line to the CSS file.