forked from briangreenery/gist
-
Notifications
You must be signed in to change notification settings - Fork 1
/
highlight.js
29 lines (22 loc) · 941 Bytes
/
highlight.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
var languages = require('./languages');
require('amd-loader');
var dom = require('jsdom/lib/jsdom/level2/html').dom.level2.html;
var browser = require('jsdom/lib/jsdom/browser/index').windowAugmentation(dom);
global.document = browser.document;
global.window = browser.window;
global.self = browser.self;
global.navigator = browser.navigator;
global.location = browser.location;
require('./public/deps/ace/ace.js');
require('./public/deps/ace/ext-static_highlight.js');
require('./public/deps/ace/theme-gist.js');
var modes = [];
for (var i = 0; i < languages.length; ++i) {
require('./public/deps/ace/mode-' + languages[i].mode);
modes[languages[i].name] = 'ace/mode/' + languages[i].mode;
}
var highlighter = ace.require('ace/ext/static_highlight');
var theme = ace.require('ace/theme/gist');
module.exports = function (data, language) {
return highlighter.renderSync(data, modes[language], theme, 1, false);
};