New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

hicat

Package Overview
Dependencies
Maintainers
1
Versions
16
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

hicat - npm Package Compare versions

Comparing version 0.5.1 to 0.6.0

4

History.md

@@ -0,1 +1,5 @@

## v0.6.0 - August 4, 2014
* Add the `--numbers` option for line numbers.
## v0.5.1 - August 3, 2014

@@ -2,0 +6,0 @@

@@ -16,3 +16,4 @@ var hljs = require('highlight.js');

* ~ lang (String): language to use
* ~ debug (Boolean): set to `true` for extra info
* ~ debug (Boolean): shows extra info if `true`
* ~ numbers (Boolean): shows line numbers if `true`
*/

@@ -24,3 +25,2 @@

var lang = options.lang || (options.filename && extname(options.filename));
var debug = options.debug;
var out;

@@ -39,5 +39,11 @@

if (!out || !out.value) throw new Error("failed to highlight");
out.ansi = html2ansi(out.value, { lang: out.language, debug: debug });
if (debug) {
// convert <span> tags to ANSI colors
out.ansi = html2ansi(out.value, {
lang: out.language,
debug: options.debug
});
// Add language comment
if (options.debug) {
var info = "/* hicat language: " + out.language + " */";

@@ -48,2 +54,15 @@ info = colorize(info, color('tag', 'debug'));

// Add line numbers
if (options.numbers) {
var i = 0;
var digits = (""+out.ansi.split("\n").length).length;
out.ansi = out.ansi.replace(/^/gm, function (s) {
i++;
var pad = digits - (""+i).length;
var prefix = Array(pad+1).join(" ") + i + ' ';
prefix = colorize(prefix, color('line_number'));
return prefix + s;
});
}
return {

@@ -50,0 +69,0 @@ ansi: out.ansi,

@@ -18,2 +18,4 @@ /*

'line_number': 'GREY',
'keyword': 'BOLD', // like 'class', 'module', etc

@@ -20,0 +22,0 @@ 'built_in': 'keyword', // like var, etc

5

lib/term.js

@@ -10,6 +10,7 @@ /**

exports.lines(function (err, max) {
if (max && count > max)
if (max && count > max) {
exports.page(str);
else
} else {
process.stdout.write(str);
}
});

@@ -16,0 +17,0 @@ };

@@ -5,3 +5,3 @@ {

"license": "MIT",
"version": "0.5.1",
"version": "0.6.0",
"description": "Command-line syntax highlighter.",

@@ -8,0 +8,0 @@ "main": "index.js",

@@ -22,2 +22,3 @@ /* jshint expr: true */

out: _cout,
stripped: _cout.replace(/\033\[[^m]*m/g, ''),
stderr: _cerr

@@ -24,0 +25,0 @@ };

@@ -96,2 +96,17 @@ require('./setup');

describe('--numbers', function () {
run('samples/ruby.rb --numbers');
success();
it('prefixes with numbers', function () {
expect(result.stripped).match(/1 class MyClass/);
expect(result.stripped).match(/2 NUMBER = 200/);
expect(result.stripped).match(/4 def method/);
});
it('colors the numbers', function () {
expect(result.out).include(hicat.colorize('3 ', hicat.color('line_number')));
});
});
describe('coercing via -l', function () {

@@ -98,0 +113,0 @@ run('samples/ruby.rb --no-pager -l markdown --debug');

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc