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.4.0 to 0.4.1

5

History.md

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

## v0.4.1 - July 31, 2014
* JSON: prevent symbols (`{ }`) from being colorized as green.
## v0.4.0 - July 31, 2014

@@ -6,2 +10,3 @@

* Internal refactors to tests, color schemes, and many others.
* Make the output of the undocumented `--debug` switch more useful.

@@ -8,0 +13,0 @@ ## v0.3.2 - July 31, 2014

35

index.js

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

if (!out || !out.value) throw new Error("failed to highlight");
out.ansi = html2ansi(out.value);
out.ansi = html2ansi(out.value, out.language);
return {

@@ -73,11 +73,20 @@ ansi: out.ansi,

* => '32'
* color('attribute', 'json')
* => '32'
*/
var color = Hicat.color = function (token) {
var code = token, newcode;
while (true) {
newcode = Hicat.colors[code];
if (newcode) code = newcode;
else if (token !== code) return code;
else return;
var color = Hicat.color = function (token, lang) {
if (lang)
return getColor(lang + ':' + token) || getColor(token);
else
return getColor(token);
function getColor (token) {
var code = token, newcode;
while (true) {
newcode = Hicat.colors[code];
if (newcode) code = newcode;
else if (token !== code) return code;
else return;
}
}

@@ -87,3 +96,3 @@ };

/**
* html2ansi() : html2ansi(str)
* html2ansi() : html2ansi(str, lang)
* (private) Converts hljs-style spans from a given HTML `str` into ANSI

@@ -96,6 +105,6 @@ * color codes.

function html2ansi (str) {
function html2ansi (str, lang) {
// do multiple passes as spans can be multiple
while (~str.indexOf('<span class="hljs-')) {
str = replaceSpan(str);
str = replaceSpan(str, lang);
}

@@ -111,6 +120,6 @@

function replaceSpan (str) {
function replaceSpan (str, lang) {
return str
.replace(/<span class="hljs-([^"]*)">([^<]*)<\/span>/g, function (_, token, s) {
var code = color(token);
var code = color(token, lang);
if (process.env.HICAT_DEBUG) {

@@ -117,0 +126,0 @@ s = s + "\033[0;30m[/" + token + "]\033[0m";

@@ -30,2 +30,3 @@ module.exports = {

value: 'string', /* html/json values */
'json:value': 'NIL',
code: 'string', /* markdown code */

@@ -32,0 +33,0 @@ link_reference: 'string', /* markdown link reference */

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

"license": "MIT",
"version": "0.4.0",
"version": "0.4.1",
"description": "Command-line syntax highlighter.",

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

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