Skip to content

Commit c4c6115

Browse files
authored
Merge pull request #13 from antonydevanchi/master
Fix issue #12: broke quotes
2 parents 84da376 + 224ede7 commit c4c6115

File tree

4 files changed

+15
-16
lines changed

4 files changed

+15
-16
lines changed

index.js

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
var hljs = require('highlight.js');
1+
var hljs = require('highlight.js');
2+
var entities = require('html-entities');
3+
24
var colorize;
35

46
/***
@@ -68,7 +70,7 @@ function hicat (str, options) {
6870
}
6971

7072
return {
71-
ansi: out.ansi,
73+
ansi: entities.decode(out.ansi, {level: 'html5', scope: 'strict'}),
7274
language: out.language,
7375
html: out.value,
7476
raw: str
@@ -152,10 +154,7 @@ function html2ansi (str, options) {
152154

153155
return str
154156
.replace(/<span class="([^"]*)">/g, '')
155-
.replace(/<\/span>/g, '')
156-
.replace(/&lt;/g, '<')
157-
.replace(/&gt;/g, '>')
158-
.replace(/&amp;/g, '&');
157+
.replace(/<\/span>/g, '');
159158
}
160159

161160
/**

package-lock.json

Lines changed: 8 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@
1616
"hicat": "bin/hicat"
1717
},
1818
"dependencies": {
19-
"highlight.js": "^10.4.1",
19+
"highlight.js": "^10.5.0",
20+
"html-entities": "^2.0.6",
2021
"minimist": "^1.2.5"
2122
},
2223
"devDependencies": {

test/test.js

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -72,12 +72,6 @@ describe('A simple example', function() {
7272
expect(out.raw).eql(input);
7373
});
7474

75-
it('produces ansi codes', function () {
76-
var inputEscaped = 'var x = 2345 + &quot;hi&quot;; /*yo*/ window.document.x = function($){};';
77-
var code = str.replace(/\033[^m]+m/g, '');
78-
expect(code).eql(inputEscaped);
79-
});
80-
8175
it('highlights numbers', function () {
8276
var fragment = hicat.colorize('2345', hicat.color('number', 'javascript'));
8377
expect(str).include(str);

0 commit comments

Comments
 (0)