This commit is contained in:
Philipp Kunz 2016-02-02 15:02:41 +01:00
parent f7bb7184ac
commit 423f634622
2 changed files with 5 additions and 20 deletions

View File

@ -188,23 +188,8 @@ var BeautylogNodeLog;
var BeautylogNodeCode; var BeautylogNodeCode;
(function (BeautylogNodeCode) { (function (BeautylogNodeCode) {
BeautylogNodeCode.init = function () { BeautylogNodeCode.init = function () {
var consoleHighlight = function (code, language) {
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"
@ -215,7 +200,7 @@ var BeautylogNodeCode;
} }
; ;
if (typeof options != "undefined") { if (typeof options != "undefined") {
codeSnippet.highlighted = consoleHighlight(codeSnippet.source, options.language); codeSnippet.highlighted = hlight(codeSnippet.source, options.language);
} }
}; };
return codeFunction; return codeFunction;

View File

@ -34,13 +34,13 @@
"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",
"hlight": "0.0.1", "hlight": "0.0.2",
"smartenv": "0.0.15" "smartenv": "0.0.15"
}, },
"devDependencies": { "devDependencies": {
"easyserve": "0.0.5", "easyserve": "0.0.5",
"gulp": "^3.9.0", "gulp": "^3.9.0",
"gulp-browser": "1.0.3", "gulp-browser": "1.0.6",
"npmts": "^1.0.12" "npmts": "^2.0.2"
} }
} }