update to hlight

This commit is contained in:
Philipp Kunz 2016-02-02 14:49:08 +01:00
parent 6340dea34a
commit 22c486a16b
3 changed files with 4 additions and 25 deletions

View File

@ -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;

View File

@ -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": {

View File

@ -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;