Skip to content

Commit

Permalink
Fix computation of line numbers for single-line code blocks. Fix #721
Browse files Browse the repository at this point in the history
  • Loading branch information
Golmote committed Aug 26, 2015
1 parent 80d8260 commit 02b220e
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
3 changes: 2 additions & 1 deletion plugins/line-numbers/prism-line-numbers.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ Prism.hooks.add('complete', function (env) {
pre.className += ' line-numbers';
}

var linesNum = env.code.match(/\n(?!$)/g).length + 1;
var match = env.code.match(/\n(?!$)/g);
var linesNum = match ? match.length + 1 : 1;
var lineNumbersWrapper;

var lines = new Array(linesNum + 1);
Expand Down
2 changes: 1 addition & 1 deletion plugins/line-numbers/prism-line-numbers.min.js

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

1 comment on commit 02b220e

@EpicTimoZz
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks alot!

Please sign in to comment.