-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathindex.js
143 lines (138 loc) · 3.34 KB
/
index.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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
'use strict';
// http://codemirror.net/mode/index.html
// https://github.com/adobe/brackets/blob/master/src/language/languages.json
// https://github.com/git/hello-world
var fs = require('fs');
var rimraf = require('rimraf').sync;
var Zip = require('node-zip');
var languages = {
'apl': {
name: 'APL',
mode: 'apl',
fileExtensions: ['apl'],
lineComment: ['⍝']
},
'cobol': {
name: 'COBOL',
mode: 'cobol',
fileExtensions: ['cbl']
},
'commonlisp': {
name: 'Common Lisp',
mode: 'commonlisp',
fileExtensions: ['clisp', 'lisp'],
lineComment: [';', ';;']
},
'd': {
name: 'D',
mode: 'd',
fileExtensions: ['d'],
lineComment: ['//'],
blockComment: ['/*', '*/']
},
'dtd': {
name: 'DTD',
mode: 'dtd',
fileExtensions: ['dtd'],
blockComment: ['<!--', '-->']
},
'ecl': {
name: 'ECL',
mode: 'ecl',
fileExtensions: ['ecl'],
lineComment: ['//'],
blockComment: ['/*', '*/']
},
'eiffel': {
name: 'Eiffel',
mode: 'eiffel',
fileExtensions: ['e', 'eiff'],
lineComment: ['--']
},
'erlang': {
name: 'Erlang',
mode: 'erlang',
fileExtensions: ['erl', 'escript'],
lineComment: ['%%']
},
'fortran': {
name: 'FORTRAN',
mode: 'fortran',
fileExtensions: ['f90', 'f77'],
lineComment: ['!']
},
'haskell': {
name: 'Haskell',
mode: 'haskell',
fileExtensions: ['hs'],
lineComment: ['--']
},
'haxe': {
name: 'Haxe',
mode: 'haxe',
fileExtensions: ['hx'],
lineComment: ['//'],
blockComment: ['/*', '*/']
},
'http': {
name: 'HTTP',
mode: 'http',
fileExtensions: ['http']
},
'julia': {
name: 'Julia',
mode: 'julia',
fileExtensions: ['jl'],
lineComment: ['#']
},
'lua': {
name: 'Lua',
mode: 'lua',
fileExtensions: ['lua'],
lineComment: ['--'],
blockComment: ['--[[', ']]']
},
'mirc': {
name: 'mIRC',
mode: 'mirc',
fileExtensions: ['mrc'],
lineComment: [';'],
},
'pegjs': {
name: 'pegjs',
mode: 'pegjs',
fileExtensions: ['pegjs']
}
};
function plugin(name, mode) {
return 'define(function (require, exports, module) {\n' +
' "use strict";\n' +
' var LanguageManager = brackets.getModule("language/LanguageManager");\n' +
' LanguageManager.defineLanguage(' + JSON.stringify(name) + ', ' +
JSON.stringify(mode) + ');\n' +
'});';
}
function pkg(name, mode) {
var extensions = mode.fileExtensions.map(function (e) { return '.' + e }).join(', ');
return JSON.stringify({
name: name,
title: mode.name + ' Syntax Highlighter',
description: 'Add syntax highlighting support for the ' + mode.name + ' language (' + extensions + ').',
homepage: 'https://github.com/ForbesLindesay/brackets-language-extensions',
version: '1.0.0',
author: 'Forbes Lindesay (http://www.forbeslindesay.co.uk)',
license: 'MIT',
engines: {
'brackets': '>=0.24.0'
}
}, null, ' ');
}
rimraf(__dirname + '/output');
fs.mkdirSync(__dirname + '/output');
Object.keys(languages).forEach(function (name) {
var zip = new Zip();
zip.file('main.js', plugin(name, languages[name]));
zip.file('package.json', pkg(name, languages[name]));
var data = new Buffer(zip.generate({base64: false, compression: 'DEFLATE'}), 'binary');
fs.writeFileSync(__dirname + '/output/' + name + '.zip', data);
});