Skip to content

Commit

Permalink
Merge pull request #13 from antonydevanchi/master
Browse files Browse the repository at this point in the history
Fix issue #12: broke quotes
  • Loading branch information
rstacruz authored Apr 8, 2021
2 parents 84da376 + 224ede7 commit c4c6115
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 16 deletions.
11 changes: 5 additions & 6 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
var hljs = require('highlight.js');
var hljs = require('highlight.js');
var entities = require('html-entities');

var colorize;

/***
Expand Down Expand Up @@ -68,7 +70,7 @@ function hicat (str, options) {
}

return {
ansi: out.ansi,
ansi: entities.decode(out.ansi, {level: 'html5', scope: 'strict'}),
language: out.language,
html: out.value,
raw: str
Expand Down Expand Up @@ -152,10 +154,7 @@ function html2ansi (str, options) {

return str
.replace(/<span class="([^"]*)">/g, '')
.replace(/<\/span>/g, '')
.replace(/&lt;/g, '<')
.replace(/&gt;/g, '>')
.replace(/&amp;/g, '&');
.replace(/<\/span>/g, '');
}

/**
Expand Down
11 changes: 8 additions & 3 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@
"hicat": "bin/hicat"
},
"dependencies": {
"highlight.js": "^10.4.1",
"highlight.js": "^10.5.0",
"html-entities": "^2.0.6",
"minimist": "^1.2.5"
},
"devDependencies": {
Expand Down
6 changes: 0 additions & 6 deletions test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,12 +72,6 @@ describe('A simple example', function() {
expect(out.raw).eql(input);
});

it('produces ansi codes', function () {
var inputEscaped = 'var x = 2345 + &quot;hi&quot;; /*yo*/ window.document.x = function($){};';
var code = str.replace(/\033[^m]+m/g, '');
expect(code).eql(inputEscaped);
});

it('highlights numbers', function () {
var fragment = hicat.colorize('2345', hicat.color('number', 'javascript'));
expect(str).include(str);
Expand Down

0 comments on commit c4c6115

Please sign in to comment.