sprunge
sprunge copied to clipboard
[Feature] Line highlight
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
we use the pygments library for highlighting - if it supports that I'd be open to it, especially in a pull request.
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'.
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.
Ooooh! Didn't think of that! Clever solution. Question: Where would we add the :target CSS then?
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-/
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.