update to hlight
This commit is contained in:
parent
6340dea34a
commit
22c486a16b
1
index.js
1
index.js
@ -216,7 +216,6 @@ var BeautylogNodeCode;
|
|||||||
;
|
;
|
||||||
if (typeof options != "undefined") {
|
if (typeof options != "undefined") {
|
||||||
codeSnippet.highlighted = consoleHighlight(codeSnippet.source, options.language);
|
codeSnippet.highlighted = consoleHighlight(codeSnippet.source, options.language);
|
||||||
console.log(codeSnippet.highlighted);
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
return codeFunction;
|
return codeFunction;
|
||||||
|
@ -34,7 +34,7 @@
|
|||||||
"cli-table2": "^0.1.9",
|
"cli-table2": "^0.1.9",
|
||||||
"colors": "1.1.2",
|
"colors": "1.1.2",
|
||||||
"highlight.js": "^9.1.0",
|
"highlight.js": "^9.1.0",
|
||||||
"html2console": "0.0.4",
|
"hlight": "0.0.1",
|
||||||
"smartenv": "0.0.15"
|
"smartenv": "0.0.15"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
|
@ -2,29 +2,9 @@
|
|||||||
module BeautylogNodeCode {
|
module BeautylogNodeCode {
|
||||||
export var init = function() {
|
export var init = function() {
|
||||||
|
|
||||||
var consoleHighlight = function(code:string,language:string) {
|
|
||||||
var fs = require('fs'),
|
|
||||||
path = require('path'),
|
|
||||||
htmlout = require('html2console'),
|
|
||||||
hljs = require('highlight.js');
|
|
||||||
|
|
||||||
var css = fs.readFileSync(path.join(__dirname, 'code.css'), 'utf8');
|
|
||||||
|
|
||||||
var result;
|
|
||||||
if (typeof language === "undefined"){
|
|
||||||
result = hljs.highlight(language, code)
|
|
||||||
} else {
|
|
||||||
result = hljs.highlightAuto(code);
|
|
||||||
};
|
|
||||||
|
|
||||||
var html = result.value;
|
|
||||||
var output = htmlout.withCSS(css);
|
|
||||||
//console.log(html);
|
|
||||||
return output('<pre class="hljs">' + html + '</pre>');
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
var codeFunction = function(codeString,options?){
|
var codeFunction = function(codeString,options?){
|
||||||
|
var hlight = require("hlight");
|
||||||
var codeSnippet = {
|
var codeSnippet = {
|
||||||
source:codeString,
|
source:codeString,
|
||||||
highlighted:"default"
|
highlighted:"default"
|
||||||
@ -34,8 +14,8 @@ module BeautylogNodeCode {
|
|||||||
return;
|
return;
|
||||||
};
|
};
|
||||||
if (typeof options != "undefined"){
|
if (typeof options != "undefined"){
|
||||||
codeSnippet.highlighted = consoleHighlight(codeSnippet.source,options.language);
|
codeSnippet.highlighted = hlight(codeSnippet.source,options.language);
|
||||||
console.log(codeSnippet.highlighted)
|
//console.log(codeSnippet.highlighted)
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
return codeFunction;
|
return codeFunction;
|
||||||
|
Loading…
Reference in New Issue
Block a user