Update the `highlightCode` method of `Diff2HtmlUI` to check if the hljs
reference is null only once (at the start). This address the "HACK"
comments by using a locally scoped variable for hljs. This way,
TypeScript is able to deduce that, after the initial null-check, hljs is
in fact not null.
Update the stickyFileHeaders default value to `true` so that it is
enabled by default. Also correct the name of this option in the
documentation by adding the missing trailing "s".
Add support for sticky file headers by adding a `stickyFileHeaders`
option to the `Diff2HtmlUI`. By default this feature is disabled. Also
document this option in the README.
The feature is implemented through an optional CSS class on top of the
pre-existing `.d2h-file-header` class. The new class is added on all
file headers if the option is set to `true` (or the `stickyFileHeaders`
method is called).
This class, `.d2h-sticky-header`, has the minimum amount of styling to
get the desired effect. The `position` and `top` values make the headers
stick to the top as long as the wrapper is in the view. The `z-index`
value is needed to ensure the header is displayed over all other content
in the wrapper. In particular, from my testing in Firefox (106.0.2), the
line numbers would display over the header if the `z-index` value isn't
set.
A default `Diff too big to be displayed` message is rendered for any file diff where `isTooBig` is `true`.
A new `diffTooBigMessage` option in render config allows to fully customize the message and receives the file index in the diff as an argument. It can be used to render a link to the raw file diff for example.
If `diffMaxChanges` is set in parser config, and its value is exceeded for a given file diff, then parsing for this file is stopped, and `isTooBig` is set to `true` in the `DiffFile`