Skip to content

Commit d66b2b0

Browse files
authored
Merge pull request #76 from wcoder/dev
2 parents 98ca4f2 + b39dba5 commit d66b2b0

7 files changed

+677
-2028
lines changed

Diff for: README.md

+52-9
Original file line numberDiff line numberDiff line change
@@ -6,41 +6,48 @@ Highlight.js line numbers plugin.
66

77
## Install
88

9-
#### Bower
9+
### Bower
10+
1011
```
1112
bower install highlightjs-line-numbers.js
1213
```
1314

14-
#### Npm
15+
### Npm
16+
1517
```
1618
npm install highlightjs-line-numbers.js
1719
```
1820

1921
#### Getting the library from CDN
22+
2023
```html
21-
<script src="//cdnjs.cloudflare.com/ajax/libs/highlightjs-line-numbers.js/2.7.0/highlightjs-line-numbers.min.js"></script>
24+
<script src="//cdnjs.cloudflare.com/ajax/libs/highlightjs-line-numbers.js/2.8.0/highlightjs-line-numbers.min.js"></script>
2225
```
26+
2327
```html
24-
<script src="//cdn.jsdelivr.net/npm/highlightjs-line-numbers.js@2.7.0/dist/highlightjs-line-numbers.min.js"></script>
28+
<script src="//cdn.jsdelivr.net/npm/highlightjs-line-numbers.js@2.8.0/dist/highlightjs-line-numbers.min.js"></script>
2529
```
2630

2731
## Usage
2832

2933
Download plugin and include file after highlight.js:
34+
3035
```html
3136
<script src="path/to/highlight.min.js"></script>
3237

3338
<script src="path/to/highlightjs-line-numbers.min.js"></script>
3439
```
3540

3641
Initialize plugin after highlight.js:
42+
3743
```js
3844
hljs.initHighlightingOnLoad();
3945

4046
hljs.initLineNumbersOnLoad();
4147
```
4248

4349
Here’s an equivalent way to calling `initLineNumbersOnLoad` using jQuery:
50+
4451
```js
4552
$(document).ready(function() {
4653
$('code.hljs').each(function(i, block) {
@@ -50,6 +57,7 @@ $(document).ready(function() {
5057
```
5158

5259
If your needs cool style, add styles by taste:
60+
5361
```css
5462
/* for block of numbers */
5563
.hljs-ln-numbers {
@@ -79,11 +87,12 @@ If your needs cool style, add styles by taste:
7987

8088
After version 2.1 plugin has optional parameter `options` - for custom setup.
8189

82-
name | type | default value | description
83-
-----------|---------|---------------|-----------------------
84-
singleLine | boolean | false | enable plugin for code block with one line
90+
version | name | type | default value | description
91+
--------|------------|---------|---------------|-----------------------
92+
v2.1 | singleLine | boolean | false | enable plugin for code block with one line
93+
v2.8 | startFrom | int | 1 | [Start numbering from a custom value](startFrom)
8594

86-
#### Examples of using
95+
### Examples of using
8796

8897
```js
8998
hljs.initLineNumbersOnLoad({
@@ -95,6 +104,40 @@ hljs.initLineNumbersOnLoad({
95104
hljs.lineNumbersBlock(myCodeBlock, myOptions);
96105
```
97106

107+
```js
108+
hljs.lineNumbersValue(myCodeBlock, myOptions);
109+
```
110+
111+
### startFrom
112+
113+
If you want numbering to start from some other value than `1`, you can specify a _numbering offset_, in one of the following ways:
114+
115+
- Specifying desired offset in `hljs.lineNumbersBlock()` call, as in:
116+
117+
```js
118+
hljs.lineNumbersBlock(myCodeBlock, {
119+
startFrom: 10
120+
});
121+
```
122+
123+
- Specifying the desired offset in `data-ln-start-from` attribute of `code` element, as in:
124+
125+
```html
126+
<pre>
127+
<code data-ln-start-from="10">
128+
...
129+
</code>
130+
</pre>
131+
```
132+
133+
In both cases numbering offset will be `10`, meaning that the numbering will start from `10`.
134+
135+
## Skipping some blocks
136+
137+
(Applies to `hljs.initLineNumbersOnLoad()` initialization only.)
138+
139+
If you want to skip some of your `code` blocks (to leave them unnumbered), you can mark them with `.nohljsln` class.
140+
98141
## CSS selectors
99142

100143
You may need to select some lines of code after rendering. For instance, you may want
@@ -110,4 +153,4 @@ CSS selector | description
110153
`.hljs-ln-numbers[data-line-number="i"]` | Select the ith line number, excluding the line of code
111154
`.hljs-ln-code[data-line-number="i"]` | Select the ith line of code, excluding the line number
112155
---
113-
&copy; 2018 Yauheni Pakala | MIT License
156+
&copy; 2020 Yauheni Pakala and [Community](https://github.com/wcoder/highlightjs-line-numbers.js/graphs/contributors) | MIT License

Diff for: bower.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "highlightjs-line-numbers.js",
3-
"version": "2.7.0",
3+
"version": "2.8.0",
44
"homepage": "https://github.com/wcoder/highlightjs-line-numbers.js",
55
"authors": [
66
"Yauheni Pakala <[email protected]>"

Diff for: dist/highlightjs-line-numbers.min.js

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)