Line context for GitHub links in onebox

In this case I’m stepping the reader through a series of changes to a file. The context is important in each case, whether I’m highlighting one line or many.

The component already highlights one line with context. The case I have here would like that same behavior applied with multiple lines.

I see the sensibility of the current scheme but I think there’s a solid case to support multi-line highlights w/context as well.

If Onebox isn’t already configurable beyond the link itself, it would need to be. Perhaps something like this?

<span
  data-onebox-highlight="true"
  data-onebox-context="5"
  >https://github.com/.../get-started/mnist_mlp.py#L16-L18</span>

There’s not much new here other than configuring what the component formats and displays.

Naively, it looks like this would be a backend only change. Consider the differences between these two onebox.json responses:

As one might expect, one has context with a highlight line and the other does not.

If the backend were configurable per request, it’s a matter of applying the existing formatting rules. I see the implementation assumes one line-to-highlight. The change to support a line range is minimal (e.g. use an array of lines-to-highlight and check for membership).