Line numbers plugin for Highlight.js
JavaScript
Latest commit 2acd76f Feb 26, 2016 @wcoder Update version
Permalink
Failed to load latest commit information.
dist Improvement loading process. Issue #8 Feb 25, 2016
src Improvement loading process. Issue #8 Feb 25, 2016
.gitignore Updated gitignore Apr 20, 2015
LICENSE Initial commit Apr 19, 2015
README.md Update version Feb 26, 2016
bower.json Update version Feb 26, 2016
gulpfile.js Added gulp and js minifier Apr 20, 2015
package.json Update version Feb 26, 2016

README.md

highlightjs-line-numbers.js version

Highlight.js line numbers plugin.

DEMO | SСREENSHOTS

Install

Bower

bower install highlightjs-line-numbers.js

Npm

npm install highlightjs-line-numbers.js

Usage

Download plugin and include file after highlight.js:

<script src="path/to/highlight.min.js"></script>

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

Adding styles:

.hljs-line-numbers {
    text-align: right;
    border-right: 1px solid #ccc;
    color: #999;
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    -khtml-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
}

Initialize plugin after highlight.js:

hljs.initHighlightingOnLoad();

hljs.initLineNumbersOnLoad();

Here’s an equivalent way to calling initLineNumbersOnLoad using jQuery:

$(document).ready(function() {
    $('code.hljs').each(function(i, block) {
        hljs.lineNumbersBlock(block);
    });
});

© 2015 Yauheni Pakala | MIT License