sprunge icon indicating copy to clipboard operation
sprunge copied to clipboard

[Feature] Line highlight

Open franciscolourenco opened this issue 11 years ago • 6 comments

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

franciscolourenco avatar Aug 03 '13 18:08 franciscolourenco

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

rupa avatar Aug 10 '13 00:08 rupa

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:

  • Allow passing the line highlight list through the query_string.
  • Close this issue with 'wont fix'.

mtahmed avatar Sep 18 '13 18:09 mtahmed

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.

Oblomov avatar Sep 23 '13 18:09 Oblomov

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

mtahmed avatar Sep 23 '13 19:09 mtahmed

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-/

Oblomov avatar Sep 24 '13 08:09 Oblomov

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.

mtahmed avatar Sep 25 '13 01:09 mtahmed