Created
September 18, 2013 14:56
-
-
Save vprimachenko/6610386 to your computer and use it in GitHub Desktop.
use highlight.js in the cosole
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var hljs = require('highlight.js'); | |
var high = hljs.highlight('cpp', 'void main<>(){return true;}').value; | |
high = high.replace(/<\/span>/g,'\x1b[0m'); | |
high = high.replace(/<span class="([a-z]+)">/g,function (match,p1) { | |
return { | |
'keyword':'\x1b[32m', | |
'types':'\x1b[34m', | |
'number':'\x1b[33m', | |
'consts':'\x1b[37m' | |
}[p1]; | |
}); | |
high = high.replace(/&/g,'&').replace(/</g,'<').replace(/>/g,'>'); | |
console.log(high); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment