Huge News!Announcing our $40M Series B led by Abstract Ventures.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.1.0 to 0.2.0

test/.travis.yml

5

History.md

@@ -0,3 +1,8 @@

## v0.2.0 - July 30, 2014
* Add `--languages` option to list available languages.
* Rename `--type` to `--lang`.
## v0.1.0 - July 30, 2014
* Initial release.

65

index.js

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

* ~ filename (string): Filename
* ~ type (string): File type
* ~ lang (string): Language to use
*/

@@ -18,18 +18,29 @@

if (!options) options = {};
var ext = options.type || (options.filename && extname(options.filename));
if (ext) {
var lang = options.lang || (options.filename && extname(options.filename));
var out;
if (lang) {
try {
str = hljs.highlight(ext, str).value;
out = hljs.highlight(ext, str);
} catch (e) {
str = hljs.highlightAuto(str).value;
out = hljs.highlightAuto(str);
}
} else {
str = hljs.highlightAuto(str).value;
out = hljs.highlightAuto(str);
}
if (!str) throw new Error("failed to highlight");
str = html2ansi(str);
return str;
if (!out || !out.value) throw new Error("failed to highlight");
out.ansi = html2ansi(out.value);
return {
ansi: out.ansi,
language: out.language,
html: out.value,
raw: str
};
}
/**
* Hicat.colors:
* The color scheme. You can modify the color scheme if you wish.
*/
Hicat.colors = {

@@ -57,2 +68,17 @@ keyword: '1',

/**
* Hicat.listLanguages():
* Returns a list of supported languages.
*/
Hicat.listLanguages = hljs.listLanguages;
/**
* extname : extname(filename)
* (private) Extracts the extension from a given `filename`.
*
* extname('hi.json')
* => 'json'
*/
function extname (fname) {

@@ -63,3 +89,11 @@ var m = fname.match(/\.([^\.]+)$/);

function color(token) {
/**
* color : color(token)
* (private) returns the color for a given token.
*
* color('string')
* => '32'
*/
var color = Hicat.color = function (token) {
var code = token, newcode;

@@ -72,4 +106,13 @@ while (true) {

}
}
};
/**
* html2ansi : html2ansi(str)
* (private) Converts hljs-style spans from a given HTML `str` into ANSI
* color codes.
*
* html2ansi('<span class="hljs-string">"hi"</span>")
* => "\033[31m"hi"\033[0m"
*/
function html2ansi (str) {

@@ -76,0 +119,0 @@ return str

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

"license": "MIT",
"version": "0.1.0",
"version": "0.2.0",
"description": "Command-line syntax highlighter.",

@@ -18,3 +18,7 @@ "main": "index.js",

"nopt": "^3.0.1"
},
"devDependencies": {
"chai": "^1.9.1",
"mocha": "^1.21.3"
}
}

16

Readme.md

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

hicat
=====
# hicat :cat:
<img src="http://ricostacruz.com/hicat/hicat.gif" align="right">
<img src="http://ricostacruz.com/hicat/hicat.gif">

@@ -15,5 +14,5 @@ `cat` with syntax highlighting. Auto-detects the language via the file

If hicat fails to detect a language, explicitly pass it `-t TYPE`.
If hicat fails to detect a language, explicitly pass it `-l LANG`.
curl http://site.com | hicat -t xml
curl http://site.com | hicat -l xml

@@ -25,2 +24,4 @@ Installation

[![npm version](https://badge.fury.io/js/hicat.svg)](https://npmjs.org/package/hicat "View this project on npm")
Usage:

@@ -31,3 +32,3 @@

Usage:
hicat [options] [file]
hicat [options] FILE
... | hicat [options]

@@ -38,3 +39,4 @@

-v, --version show version info and exit
-t, --type TYPE use a given file type
-l, --lang LANG use a given language
--languages list available languages

@@ -41,0 +43,0 @@ Thanks

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