Skip to content

Implementing line number offset. #65

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 30, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,33 @@ hljs.initLineNumbersOnLoad({
hljs.lineNumbersBlock(myCodeBlock, myOptions);
```

## Skipping some blocks

(Applies to `hljs.initLineNumbersOnLoad()` initialization only.)

If you want to skip some of your `code` blocks (to leave them unnumbered), you can mark
them with `.hlnoln` class.

## Start numbering from a custom value

If you want numbering to start from some other value than `1`, you can specify a
_numbering offset_, in one of the following ways:

* Specifying desired offset in `hljs.lineNumbersBlock()` call, as in:
```js
hljs.lineNumbersBlock(myCodeBlock, myOptions, 10); // Numbering will start from 11
```
* Specifying the desired offset in `data-ln-offset` attribute of `code` element, as in:
```html
<pre>
<code data-ln-offset="10">
...
</code>
</pre>
```

In both cases numbering offset will be `10`, meaning that the numbering will start from `11`.

## CSS selectors

You may need to select some lines of code after rendering. For instance, you may want
Expand Down
2 changes: 1 addition & 1 deletion dist/highlightjs-line-numbers.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading