1 |
|
2 | exports.context = function(input, lineno, columnno, linebreak) {
|
3 | linebreak = linebreak || '!LB!';
|
4 |
|
5 | var lines = input.split(linebreak)
|
6 | , contextSize = lineno === 0 && columnno === 0 ? lines.length - 1 : 3
|
7 | , start = Math.max(0, lineno - contextSize)
|
8 | , end = Math.min(lines.length, lineno + contextSize);
|
9 |
|
10 | return lines
|
11 | .slice(start, end)
|
12 | .map(function(line, i, all){
|
13 | var curr = i + start + 1;
|
14 |
|
15 | return (curr === lineno ? ' > ' : ' ')
|
16 | + (curr < 10 ? ' ' : '')
|
17 | + curr
|
18 | + ' | '
|
19 | + line;
|
20 | }).join('\n');
|
21 | } |
\ | No newline at end of file |