Comparing version 0.4.1 to 0.4.2
var redeyed = require('redeyed') | ||
, theme = require('../themes/default') | ||
, colors = require('ansicolors') | ||
, colorSurround = colors.brightBlack | ||
, colorSurround = colors.brightBlack | ||
, surroundClose = '\u001b[39m' | ||
; | ||
@@ -54,3 +56,4 @@ | ||
for (var i = 0; i < linesLen; i++) { | ||
lineno = colorSurround(pad(i + firstline, totalDigits) + ': ') | ||
// Don't close the escape sequence here in order to not break multi line code highlights like block comments | ||
lineno = colorSurround(pad(i + firstline, totalDigits) + ': ').replace(surroundClose, ''); | ||
lines.push(lineno + highlightedLines[i]); | ||
@@ -57,0 +60,0 @@ } |
{ | ||
"name": "cardinal", | ||
"version": "0.4.1", | ||
"version": "0.4.2", | ||
"description": "Syntax highlights JavaScript code with ANSI colors to be printed to the terminal.", | ||
@@ -5,0 +5,0 @@ "main": "cardinal.js", |
@@ -42,3 +42,3 @@ 'use strict'; | ||
var highlighted = cardinal.highlight(code, { linenos: true }); | ||
t.equals(highlighted, '\u001b[90m1: \u001b[39m\u001b[94mfunction\u001b[39m \u001b[37mfoo\u001b[39m\u001b[90m(\u001b[39m\u001b[90m)\u001b[39m \u001b[33m{\u001b[39m \u001b[32mvar\u001b[39m \u001b[37ma\u001b[39m \u001b[93m=\u001b[39m \u001b[34m3\u001b[39m\u001b[90m;\u001b[39m \u001b[31mreturn\u001b[39m \u001b[37ma\u001b[39m \u001b[93m>\u001b[39m \u001b[34m2\u001b[39m \u001b[93m?\u001b[39m \u001b[91mtrue\u001b[39m \u001b[93m:\u001b[39m \u001b[91mfalse\u001b[39m\u001b[90m;\u001b[39m \u001b[33m}\u001b[39m') | ||
t.equals(highlighted, '\u001b[90m1: \u001b[94mfunction\u001b[39m \u001b[37mfoo\u001b[39m\u001b[90m(\u001b[39m\u001b[90m)\u001b[39m \u001b[33m{\u001b[39m \u001b[32mvar\u001b[39m \u001b[37ma\u001b[39m \u001b[93m=\u001b[39m \u001b[34m3\u001b[39m\u001b[90m;\u001b[39m \u001b[31mreturn\u001b[39m \u001b[37ma\u001b[39m \u001b[93m>\u001b[39m \u001b[34m2\u001b[39m \u001b[93m?\u001b[39m \u001b[91mtrue\u001b[39m \u001b[93m:\u001b[39m \u001b[91mfalse\u001b[39m\u001b[90m;\u001b[39m \u001b[33m}\u001b[39m') | ||
t.end() | ||
@@ -49,3 +49,3 @@ }) | ||
var highlighted = cardinal.highlight(code, { linenos: true, firstline: 99 }); | ||
t.equals(highlighted, '\u001b[90m99: \u001b[39m\u001b[94mfunction\u001b[39m \u001b[37mfoo\u001b[39m\u001b[90m(\u001b[39m\u001b[90m)\u001b[39m \u001b[33m{\u001b[39m \u001b[32mvar\u001b[39m \u001b[37ma\u001b[39m \u001b[93m=\u001b[39m \u001b[34m3\u001b[39m\u001b[90m;\u001b[39m \u001b[31mreturn\u001b[39m \u001b[37ma\u001b[39m \u001b[93m>\u001b[39m \u001b[34m2\u001b[39m \u001b[93m?\u001b[39m \u001b[91mtrue\u001b[39m \u001b[93m:\u001b[39m \u001b[91mfalse\u001b[39m\u001b[90m;\u001b[39m \u001b[33m}\u001b[39m') | ||
t.equals(highlighted, '\u001b[90m99: \u001b[94mfunction\u001b[39m \u001b[37mfoo\u001b[39m\u001b[90m(\u001b[39m\u001b[90m)\u001b[39m \u001b[33m{\u001b[39m \u001b[32mvar\u001b[39m \u001b[37ma\u001b[39m \u001b[93m=\u001b[39m \u001b[34m3\u001b[39m\u001b[90m;\u001b[39m \u001b[31mreturn\u001b[39m \u001b[37ma\u001b[39m \u001b[93m>\u001b[39m \u001b[34m2\u001b[39m \u001b[93m?\u001b[39m \u001b[91mtrue\u001b[39m \u001b[93m:\u001b[39m \u001b[91mfalse\u001b[39m\u001b[90m;\u001b[39m \u001b[33m}\u001b[39m') | ||
t.end() | ||
@@ -60,3 +60,3 @@ }) | ||
var highlighted = cardinal.highlight(multilineCode, { linenos: true }); | ||
t.equals(highlighted,'\u001b[90m1: \u001b[39m\u001b[94mfunction\u001b[39m \u001b[37mfoo\u001b[39m\u001b[90m(\u001b[39m\u001b[90m)\u001b[39m \u001b[33m{\u001b[39m\n\u001b[90m2: \u001b[39m \u001b[31mreturn\u001b[39m \u001b[34m1\u001b[39m\u001b[90m;\u001b[39m\n\u001b[90m3: \u001b[39m \u001b[33m}\u001b[39m') | ||
t.equals(highlighted,'\u001b[90m1: \u001b[94mfunction\u001b[39m \u001b[37mfoo\u001b[39m\u001b[90m(\u001b[39m\u001b[90m)\u001b[39m \u001b[33m{\u001b[39m\n\u001b[90m2: \u001b[31mreturn\u001b[39m \u001b[34m1\u001b[39m\u001b[90m;\u001b[39m\n\u001b[90m3: \u001b[33m}\u001b[39m') | ||
t.end() | ||
@@ -71,4 +71,4 @@ }) | ||
var highlighted = cardinal.highlight(multilineCode, { linenos: true, firstline: 99 }); | ||
t.equals(highlighted,'\u001b[90m 99: \u001b[39m\u001b[94mfunction\u001b[39m \u001b[37mfoo\u001b[39m\u001b[90m(\u001b[39m\u001b[90m)\u001b[39m \u001b[33m{\u001b[39m\n\u001b[90m100: \u001b[39m \u001b[31mreturn\u001b[39m \u001b[34m1\u001b[39m\u001b[90m;\u001b[39m\n\u001b[90m101: \u001b[39m \u001b[33m}\u001b[39m') | ||
t.equals(highlighted,'\u001b[90m 99: \u001b[94mfunction\u001b[39m \u001b[37mfoo\u001b[39m\u001b[90m(\u001b[39m\u001b[90m)\u001b[39m \u001b[33m{\u001b[39m\n\u001b[90m100: \u001b[31mreturn\u001b[39m \u001b[34m1\u001b[39m\u001b[90m;\u001b[39m\n\u001b[90m101: \u001b[33m}\u001b[39m') | ||
t.end() | ||
}) |
@@ -1,33 +0,3 @@ | ||
/* | ||
* Copy this file and use it as a starting point for your custom cardinal color theme. | ||
* Just fill in or change the entries for the tokens you want to color | ||
* Keep in mind that more specific configurations override less specific ones. | ||
*/ | ||
var colors = require('ansicolors'); | ||
// Don't touch this definition | ||
var colorNums = { | ||
white : 37 | ||
, black : 30 | ||
, blue : 34 | ||
, cyan : 36 | ||
, green : 32 | ||
, magenta : 35 | ||
, red : 31 | ||
, yellow : 33 | ||
, brightBlack : 90 | ||
, brightRed : 91 | ||
, brightGreen : 92 | ||
, brightYellow : 93 | ||
, brightBlue : 94 | ||
, brightMagenta : 95 | ||
, brightCyan : 96 | ||
, brightWhite : 97 | ||
} | ||
, colors = {}; | ||
Object.keys(colorNums).forEach(function (k) { | ||
colors[k] = '\u001b[' + colorNums[k] + 'm:\u001b[39m'; | ||
}); | ||
// Change the below definitions in order to tweak the color theme. | ||
@@ -163,3 +133,13 @@ module.exports = { | ||
// line comment | ||
, Line: { | ||
_default: colors.brightBlack | ||
} | ||
/* block comment */ | ||
, Block: { | ||
_default: colors.brightBlack | ||
} | ||
, _default: undefined | ||
}; |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
52809
41
1202
15